<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
	<head>
		<title>Compile Blocks and Lines</title>
<link href="../docs-assets/Breadcrumbs.css" rel="stylesheet" rev="stylesheet" type="text/css">
		<meta name="viewport" content="width=device-width initial-scale=1">
		<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
		<meta http-equiv="Content-Language" content="en-gb">

<link href="../docs-assets/Contents.css" rel="stylesheet" rev="stylesheet" type="text/css">
<link href="../docs-assets/Progress.css" rel="stylesheet" rev="stylesheet" type="text/css">
<link href="../docs-assets/Navigation.css" rel="stylesheet" rev="stylesheet" type="text/css">
<link href="../docs-assets/Fonts.css" rel="stylesheet" rev="stylesheet" type="text/css">
<link href="../docs-assets/Base.css" rel="stylesheet" rev="stylesheet" type="text/css">
<script>
function togglePopup(material_id) {
  var popup = document.getElementById(material_id);
  popup.classList.toggle("show");
}
</script>

<link href="../docs-assets/Popups.css" rel="stylesheet" rev="stylesheet" type="text/css">
<link href="../docs-assets/Colours.css" rel="stylesheet" rev="stylesheet" type="text/css">
		
	</head>
	<body class="commentary-font">
		<nav role="navigation">
		<h1><a href="../index.html"><img src="../docs-assets/Inform.png" height=72> </a></h1>
<ul><li><a href="../index.html">home</a></li>
</ul><h2>Compiler</h2><ul>
<li><a href="../structure.html">structure</a></li>
<li><a href="../inbuildn.html">inbuild</a></li>
<li><a href="../inform7n.html">inform7</a></li>
<li><a href="../intern.html">inter</a></li>
<li><a href="../services.html">services</a></li>
<li><a href="../secrets.html">secrets</a></li>
</ul><h2>Other Tools</h2><ul>
<li><a href="../inblorbn.html">inblorb</a></li>
<li><a href="../inform6.html">inform6</a></li>
<li><a href="../inpolicyn.html">inpolicy</a></li>
</ul><h2>Resources</h2><ul>
<li><a href="../extensions.html">extensions</a></li>
<li><a href="../kits.html">kits</a></li>
</ul><h2>Repository</h2><ul>
<li><a href="https://github.com/ganelson/inform"><img src="../docs-assets/github.png" height=0> github</a></li>
</ul><h2>Related Projects</h2><ul>
<li><a href="https://github.com/ganelson/inweb"><img src="../docs-assets/github.png" height=0> inweb</a></li>
<li><a href="https://github.com/ganelson/intest"><img src="../docs-assets/github.png" height=0> intest</a></li>
</ul>
		</nav>
		<main role="main">
		<!-- Weave of 'Compile Blocks and Lines' generated by inweb -->
<div class="breadcrumbs">
    <ul class="crumbs"><li><a href="../index.html">Home</a></li><li><a href="../inform7n.html">Inform7</a></li><li><a href="index.html">imperative</a></li><li><a href="index.html#5">Chapter 5: Invocations</a></li><li><b>Compile Blocks and Lines</b></li></ul></div>
<p class="purpose">Compiling a code block of lines from an imperative definition.</p>

<ul class="toc"><li><a href="5-cbal.html#SP1">&#167;1. Blocks of code</a></li><li><a href="5-cbal.html#SP4">&#167;4. Individual lines of code</a></li><li><a href="5-cbal.html#SP4_3">&#167;4.3. Head code for lines</a></li><li><a href="5-cbal.html#SP4_4">&#167;4.4. Midriff code for lines</a></li><li><a href="5-cbal.html#SP4_5">&#167;4.5. Tail code for lines</a></li><li><a href="5-cbal.html#SP5">&#167;5. Nows</a></li><li><a href="5-cbal.html#SP6">&#167;6. The evaluator</a></li><li><a href="5-cbal.html#SP7">&#167;7. Validating sequences of say invocations</a></li></ul><hr class="tocbar">

<p class="commentary firstcommentary"><a id="SP1" class="paragraph-anchor"></a><b>&#167;1. Blocks of code.</b>As this section of code opens, we are looking at the parse tree for the body
of a rule or phrase definition. A request has been made to compile (a version of)
this into an Inter function; the stack frame for that has been sorted out, and
the function begun. Now we must compile the actual code to go into the function;
the test group <span class="extract"><span class="extract-syntax">:invocations</span></span> exercises all of this.
</p>

<p class="commentary">Here is a typical example rule, taken from the Standard Rules:
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="identifier-syntax">Report</span><span class="plain-syntax"> </span><span class="identifier-syntax">an</span><span class="plain-syntax"> </span><span class="identifier-syntax">actor</span><span class="plain-syntax"> </span><span class="identifier-syntax">waiting</span><span class="plain-syntax"> (</span><span class="identifier-syntax">this</span><span class="plain-syntax"> </span><span class="identifier-syntax">is</span><span class="plain-syntax"> </span><span class="identifier-syntax">the</span><span class="plain-syntax"> </span><span class="identifier-syntax">standard</span><span class="plain-syntax"> </span><span class="identifier-syntax">report</span><span class="plain-syntax"> </span><span class="identifier-syntax">waiting</span><span class="plain-syntax"> </span><span class="identifier-syntax">rule</span><span class="plain-syntax">):</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">if</span><span class="plain-syntax"> </span><span class="identifier-syntax">the</span><span class="plain-syntax"> </span><span class="identifier-syntax">actor</span><span class="plain-syntax"> </span><span class="identifier-syntax">is</span><span class="plain-syntax"> </span><span class="identifier-syntax">the</span><span class="plain-syntax"> </span><span class="identifier-syntax">player</span><span class="plain-syntax">:</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">if</span><span class="plain-syntax"> </span><span class="identifier-syntax">the</span><span class="plain-syntax"> </span><span class="identifier-syntax">action</span><span class="plain-syntax"> </span><span class="identifier-syntax">is</span><span class="plain-syntax"> </span><span class="identifier-syntax">not</span><span class="plain-syntax"> </span><span class="identifier-syntax">silent</span><span class="plain-syntax">:</span>
<span class="plain-syntax">            </span><span class="identifier-syntax">now</span><span class="plain-syntax"> </span><span class="identifier-syntax">the</span><span class="plain-syntax"> </span><span class="identifier-syntax">prior</span><span class="plain-syntax"> </span><span class="identifier-syntax">named</span><span class="plain-syntax"> </span><span class="identifier-syntax">object</span><span class="plain-syntax"> </span><span class="identifier-syntax">is</span><span class="plain-syntax"> </span><span class="identifier-syntax">nothing</span><span class="plain-syntax">;</span>
<span class="plain-syntax">            </span><span class="identifier-syntax">say</span><span class="plain-syntax"> </span><span class="string-syntax">"Time [pass]."</span><span class="plain-syntax"> (</span><span class="identifier-syntax">A</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">otherwise</span><span class="plain-syntax">:</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">say</span><span class="plain-syntax"> </span><span class="string-syntax">"[The actor] [wait]."</span><span class="plain-syntax"> (</span><span class="identifier-syntax">B</span><span class="plain-syntax">).</span>
</pre>
<p class="commentary">In the parse tree, this now looks like so:
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="identifier-syntax">IMPERATIVE_NT</span><span class="character-syntax">'report an actor waiting ( this is the standard report waiting'</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">CODE_BLOCK_NT</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">CODE_BLOCK_NT</span>
<span class="plain-syntax">            </span><span class="identifier-syntax">INVOCATION_LIST_NT</span><span class="character-syntax">'if the actor is the player'</span>
<span class="plain-syntax">            </span><span class="identifier-syntax">CODE_BLOCK_NT</span>
<span class="plain-syntax">                </span><span class="identifier-syntax">CODE_BLOCK_NT</span>
<span class="plain-syntax">                    </span><span class="identifier-syntax">INVOCATION_LIST_NT</span><span class="character-syntax">'if the action is not silent'</span>
<span class="plain-syntax">                    </span><span class="identifier-syntax">CODE_BLOCK_NT</span>
<span class="plain-syntax">                        </span><span class="identifier-syntax">INVOCATION_LIST_NT</span><span class="character-syntax">'now the prior named object is nothing'</span>
<span class="plain-syntax">                        </span><span class="identifier-syntax">CODE_BLOCK_NT</span><span class="character-syntax">'say "Time [pass]." ( a )'</span>
<span class="plain-syntax">                            </span><span class="identifier-syntax">INVOCATION_LIST_SAY_NT</span><span class="character-syntax">'"Time [pass]." ( a )'</span>
<span class="plain-syntax">            </span><span class="identifier-syntax">CODE_BLOCK_NT</span><span class="character-syntax">'otherwise'</span>
<span class="plain-syntax">                </span><span class="identifier-syntax">CODE_BLOCK_NT</span><span class="character-syntax">'say "[The actor] [wait]." ( b )'</span>
<span class="plain-syntax">                    </span><span class="identifier-syntax">INVOCATION_LIST_SAY_NT</span><span class="character-syntax">'"[The actor] [wait]." ( b )'</span>
</pre>
<p class="commentary">This diagram has been simplified to remove the child nodes of the <span class="extract"><span class="extract-syntax">INVOCATION_LIST_NT</span></span>
and <span class="extract"><span class="extract-syntax">INVOCATION_LIST_SAY_NT</span></span> nodes; the point is to show the structure of the code
blocks here.
</p>

<p class="commentary">We work recursively down through these blocks. Note that the entire definition
always hangs from a single top-level <span class="extract"><span class="extract-syntax">CODE_BLOCK_NT</span></span>.
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="reserved-syntax">void</span><span class="plain-syntax"> </span><span class="function-syntax">CompileBlocksAndLines::full_definition_body</span><button class="popup" onclick="togglePopup('usagePopup1')"><span class="comment-syntax">?</span><span class="popuptext" id="usagePopup1">Usage of <span class="code-font"><span class="function-syntax">CompileBlocksAndLines::full_definition_body</span></span>:<br/>Compile Imperative Definitions - <a href="3-cid.html#SP2_3">&#167;2.3</a></span></button><span class="plain-syntax">(</span><span class="reserved-syntax">int</span><span class="plain-syntax"> </span><span class="identifier-syntax">statement_count</span><span class="plain-syntax">, </span><span class="identifier-syntax">parse_node</span><span class="plain-syntax"> *</span><span class="identifier-syntax">body</span><span class="plain-syntax">,</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">int</span><span class="plain-syntax"> </span><span class="identifier-syntax">allow_implied_newlines</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">text_provenance</span><span class="plain-syntax"> </span><span class="identifier-syntax">last_loc</span><span class="plain-syntax"> = </span><span class="identifier-syntax">Provenance::nowhere</span><span class="plain-syntax">();</span>
<span class="plain-syntax">    </span><a href="5-cbal.html#SP2" class="function-link"><span class="function-syntax">CompileBlocksAndLines::code_block</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">statement_count</span><span class="plain-syntax">, </span><span class="identifier-syntax">body</span><span class="plain-syntax">, </span><span class="identifier-syntax">TRUE</span><span class="plain-syntax">, </span><span class="identifier-syntax">allow_implied_newlines</span><span class="plain-syntax">, &amp;</span><span class="identifier-syntax">last_loc</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">Provenance::is_somewhere</span><span class="plain-syntax">(</span><span class="identifier-syntax">last_loc</span><span class="plain-syntax">)) {</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">last_loc</span><span class="plain-syntax"> = </span><span class="identifier-syntax">Provenance::nowhere</span><span class="plain-syntax">();</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">EmitCode::provenance</span><span class="plain-syntax">(</span><span class="identifier-syntax">last_loc</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    }</span>
<span class="plain-syntax">}</span>
</pre>
<p class="commentary firstcommentary"><a id="SP2" class="paragraph-anchor"></a><b>&#167;2. </b>See <a href="../words-module/4-nnt.html" class="internal">Nonterminals (in words)</a> for an explanation of what it means for a nonterminal
such as &lt;s-value-uncached&gt; to be "multiplicitous": briefly, though, it causes
&lt;s-value-uncached&gt; to return all possible interpretations of the text as a list
of nodes joined by <span class="extract"><span class="extract-syntax">-&gt;next_alternative</span></span>, rather than returning just the single
most "likely" interpretation.
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="reserved-syntax">int</span><span class="plain-syntax"> </span><span class="function-syntax">CompileBlocksAndLines::code_block</span><button class="popup" onclick="togglePopup('usagePopup2')"><span class="comment-syntax">?</span><span class="popuptext" id="usagePopup2">Usage of <span class="code-font"><span class="function-syntax">CompileBlocksAndLines::code_block</span></span>:<br/><a href="5-cbal.html#SP1">&#167;1</a>, <a href="5-cbal.html#SP4_4_3">&#167;4.4.3</a>, <a href="5-cbal.html#SP4_4_4_1_1">&#167;4.4.4.1.1</a>, <a href="5-cbal.html#SP4_4_4_3">&#167;4.4.4.3</a>, <a href="5-cbal.html#SP4_4_4_1_2">&#167;4.4.4.1.2</a>, <a href="5-cbal.html#SP4_4_4_6">&#167;4.4.4.6</a>, <a href="5-cbal.html#SP4_5_3">&#167;4.5.3</a>, <a href="5-cbal.html#SP4_5_5">&#167;4.5.5</a></span></button><span class="plain-syntax">(</span><span class="reserved-syntax">int</span><span class="plain-syntax"> </span><span class="identifier-syntax">statement_count</span><span class="plain-syntax">, </span><span class="identifier-syntax">parse_node</span><span class="plain-syntax"> *</span><span class="identifier-syntax">block</span><span class="plain-syntax">, </span><span class="reserved-syntax">int</span><span class="plain-syntax"> </span><span class="identifier-syntax">top_level</span><span class="plain-syntax">,</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">int</span><span class="plain-syntax"> </span><span class="identifier-syntax">allow_implied_newlines</span><span class="plain-syntax">, </span><span class="identifier-syntax">text_provenance</span><span class="plain-syntax"> *</span><span class="identifier-syntax">last_loc</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">block</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">Node::get_type</span><span class="plain-syntax">(</span><span class="identifier-syntax">block</span><span class="plain-syntax">) != </span><span class="identifier-syntax">CODE_BLOCK_NT</span><span class="plain-syntax">) </span><span class="identifier-syntax">internal_error</span><span class="plain-syntax">(</span><span class="string-syntax">"not a code block"</span><span class="plain-syntax">);</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">int</span><span class="plain-syntax"> </span><span class="identifier-syntax">saved_mult</span><span class="plain-syntax"> = </span><span class="function-syntax">&lt;s-value-uncached&gt;-&gt;</span><span class="identifier-syntax">multiplicitous</span><span class="plain-syntax">;</span>
<span class="plain-syntax">        </span><span class="function-syntax">&lt;s-value-uncached&gt;-&gt;</span><span class="identifier-syntax">multiplicitous</span><span class="plain-syntax"> = </span><span class="identifier-syntax">TRUE</span><span class="plain-syntax">;</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">int</span><span class="plain-syntax"> </span><span class="identifier-syntax">block_size</span><span class="plain-syntax"> = </span><span class="constant-syntax">0</span><span class="plain-syntax">, </span><span class="identifier-syntax">singleton</span><span class="plain-syntax"> = </span><span class="identifier-syntax">FALSE</span><span class="plain-syntax">;</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">for</span><span class="plain-syntax"> (</span><span class="identifier-syntax">parse_node</span><span class="plain-syntax"> *</span><span class="identifier-syntax">p</span><span class="plain-syntax"> = </span><span class="identifier-syntax">block</span><span class="plain-syntax">-&gt;</span><span class="identifier-syntax">down</span><span class="plain-syntax">; </span><span class="identifier-syntax">p</span><span class="plain-syntax">; </span><span class="identifier-syntax">p</span><span class="plain-syntax"> = </span><span class="identifier-syntax">p</span><span class="plain-syntax">-&gt;</span><span class="identifier-syntax">next</span><span class="plain-syntax">) </span><span class="identifier-syntax">block_size</span><span class="plain-syntax">++;</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">if</span><span class="plain-syntax"> ((</span><span class="identifier-syntax">top_level</span><span class="plain-syntax"> == </span><span class="identifier-syntax">FALSE</span><span class="plain-syntax">) &amp;&amp; (</span><span class="identifier-syntax">block_size</span><span class="plain-syntax"> == </span><span class="constant-syntax">1</span><span class="plain-syntax">)) </span><span class="identifier-syntax">singleton</span><span class="plain-syntax"> = </span><span class="identifier-syntax">TRUE</span><span class="plain-syntax">;</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">for</span><span class="plain-syntax"> (</span><span class="identifier-syntax">parse_node</span><span class="plain-syntax"> *</span><span class="identifier-syntax">p</span><span class="plain-syntax"> = </span><span class="identifier-syntax">block</span><span class="plain-syntax">-&gt;</span><span class="identifier-syntax">down</span><span class="plain-syntax">; </span><span class="identifier-syntax">p</span><span class="plain-syntax">; </span><span class="identifier-syntax">p</span><span class="plain-syntax"> = </span><span class="identifier-syntax">p</span><span class="plain-syntax">-&gt;</span><span class="identifier-syntax">next</span><span class="plain-syntax">)</span>
<span class="plain-syntax">            </span><span class="identifier-syntax">statement_count</span><span class="plain-syntax"> =</span>
<span class="plain-syntax">                </span><a href="5-cbal.html#SP4" class="function-link"><span class="function-syntax">CompileBlocksAndLines::code_line</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">statement_count</span><span class="plain-syntax">, </span><span class="identifier-syntax">p</span><span class="plain-syntax">, </span><span class="identifier-syntax">singleton</span><span class="plain-syntax">,</span>
<span class="plain-syntax">                    </span><span class="identifier-syntax">allow_implied_newlines</span><span class="plain-syntax">, </span><span class="identifier-syntax">last_loc</span><span class="plain-syntax">);</span>
<span class="plain-syntax">        </span><span class="function-syntax">&lt;s-value-uncached&gt;-&gt;</span><span class="identifier-syntax">multiplicitous</span><span class="plain-syntax"> = </span><span class="identifier-syntax">saved_mult</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    }</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="identifier-syntax">statement_count</span><span class="plain-syntax">;</span>
<span class="plain-syntax">}</span>
</pre>
<p class="commentary firstcommentary"><a id="SP3" class="paragraph-anchor"></a><b>&#167;3. </b>There's nothing special about singleton blocks except that we want to issue
problem messages for something like this:
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="plain-syntax">    </span><span class="identifier-syntax">if</span><span class="plain-syntax"> </span><span class="identifier-syntax">the</span><span class="plain-syntax"> </span><span class="identifier-syntax">player</span><span class="plain-syntax"> </span><span class="identifier-syntax">is</span><span class="plain-syntax"> </span><span class="identifier-syntax">in</span><span class="plain-syntax"> </span><span class="identifier-syntax">the</span><span class="plain-syntax"> </span><span class="identifier-syntax">Hall</span><span class="plain-syntax"> </span><span class="identifier-syntax">of</span><span class="plain-syntax"> </span><span class="identifier-syntax">Mirrors</span><span class="plain-syntax">:</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">let</span><span class="plain-syntax"> </span><span class="identifier-syntax">the</span><span class="plain-syntax"> </span><span class="identifier-syntax">court</span><span class="plain-syntax"> </span><span class="identifier-syntax">favourite</span><span class="plain-syntax"> </span><span class="identifier-syntax">be</span><span class="plain-syntax"> </span><span class="identifier-syntax">Moliere</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">if</span><span class="plain-syntax"> </span><span class="identifier-syntax">Louis</span><span class="plain-syntax"> </span><span class="identifier-syntax">is</span><span class="plain-syntax"> </span><span class="identifier-syntax">happy</span><span class="plain-syntax">:</span>
<span class="plain-syntax">        ...</span>
</pre>
<p class="commentary">...where the "let" phrase can have no meaningful effect, since "court favourite"
is destroyed immediately after its creation. So in order to check for that, we
keep the following state variable:
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="reserved-syntax">int</span><span class="plain-syntax"> </span><span class="identifier-syntax">compiling_single_line_block</span><span class="plain-syntax"> = </span><span class="identifier-syntax">FALSE</span><span class="plain-syntax">;</span>
<span class="reserved-syntax">int</span><span class="plain-syntax"> </span><span class="function-syntax">CompileBlocksAndLines::compiling_single_line_block</span><span class="plain-syntax">(</span><span class="reserved-syntax">void</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="identifier-syntax">compiling_single_line_block</span><span class="plain-syntax">;</span>
<span class="plain-syntax">}</span>
</pre>
<p class="commentary firstcommentary"><a id="SP4" class="paragraph-anchor"></a><b>&#167;4. Individual lines of code.</b>So, then, this is called on each child node of a <span class="extract"><span class="extract-syntax">CODE_BLOCK_NT</span></span> in turn:
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="reserved-syntax">int</span><span class="plain-syntax"> </span><span class="function-syntax">CompileBlocksAndLines::code_line</span><button class="popup" onclick="togglePopup('usagePopup3')"><span class="comment-syntax">?</span><span class="popuptext" id="usagePopup3">Usage of <span class="code-font"><span class="function-syntax">CompileBlocksAndLines::code_line</span></span>:<br/><a href="5-cbal.html#SP2">&#167;2</a></span></button><span class="plain-syntax">(</span><span class="reserved-syntax">int</span><span class="plain-syntax"> </span><span class="identifier-syntax">statement_count</span><span class="plain-syntax">, </span><span class="identifier-syntax">parse_node</span><span class="plain-syntax"> *</span><span class="identifier-syntax">p</span><span class="plain-syntax">, </span><span class="reserved-syntax">int</span><span class="plain-syntax"> </span><span class="identifier-syntax">as_singleton</span><span class="plain-syntax">,</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">int</span><span class="plain-syntax"> </span><span class="identifier-syntax">allow_implied_newlines</span><span class="plain-syntax">, </span><span class="identifier-syntax">text_provenance</span><span class="plain-syntax"> *</span><span class="identifier-syntax">last_loc</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">compiling_single_line_block</span><span class="plain-syntax"> = </span><span class="identifier-syntax">as_singleton</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">control_structure_phrase</span><span class="plain-syntax"> *</span><span class="identifier-syntax">csp</span><span class="plain-syntax"> = </span><span class="identifier-syntax">Node::get_control_structure_used</span><span class="plain-syntax">(</span><span class="identifier-syntax">p</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">parse_node</span><span class="plain-syntax"> *</span><span class="identifier-syntax">to_compile</span><span class="plain-syntax"> = </span><span class="identifier-syntax">p</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">ControlStructures::opens_block</span><span class="plain-syntax">(</span><span class="identifier-syntax">csp</span><span class="plain-syntax">)) {</span>
<span class="plain-syntax">        </span><a href="3-cb.html#SP9" class="function-link"><span class="function-syntax">CodeBlocks::beginning_block_phrase</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">csp</span><span class="plain-syntax">);</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">to_compile</span><span class="plain-syntax"> = </span><span class="identifier-syntax">p</span><span class="plain-syntax">-&gt;</span><span class="identifier-syntax">down</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    }</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">statement_count</span><span class="plain-syntax">++;</span>
<span class="plain-syntax">    </span><span class="named-paragraph-container code-font"><a href="5-cbal.html#SP4_1" class="named-paragraph-link"><span class="named-paragraph">Compile a comment about this line</span><span class="named-paragraph-number">4.1</span></a></span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="named-paragraph-container code-font"><a href="5-cbal.html#SP4_2" class="named-paragraph-link"><span class="named-paragraph">Compile a location reference for this line</span><span class="named-paragraph-number">4.2</span></a></span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">int</span><span class="plain-syntax"> </span><span class="identifier-syntax">L</span><span class="plain-syntax"> = </span><span class="identifier-syntax">EmitCode::level</span><span class="plain-syntax">();</span>
<span class="plain-syntax">    </span><span class="named-paragraph-container code-font"><a href="5-cbal.html#SP4_3" class="named-paragraph-link"><span class="named-paragraph">Compile the head</span><span class="named-paragraph-number">4.3</span></a></span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="named-paragraph-container code-font"><a href="5-cbal.html#SP4_4" class="named-paragraph-link"><span class="named-paragraph">Compile the midriff</span><span class="named-paragraph-number">4.4</span></a></span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="named-paragraph-container code-font"><a href="5-cbal.html#SP4_5" class="named-paragraph-link"><span class="named-paragraph">Compile the tail</span><span class="named-paragraph-number">4.5</span></a></span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">compiling_single_line_block</span><span class="plain-syntax"> = </span><span class="identifier-syntax">FALSE</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="identifier-syntax">statement_count</span><span class="plain-syntax">;</span>
<span class="plain-syntax">}</span>
</pre>
<p class="commentary firstcommentary"><a id="SP4_1" class="paragraph-anchor"></a><b>&#167;4.1. </b><span class="named-paragraph-container code-font"><span class="named-paragraph-defn">Compile a comment about this line</span><span class="named-paragraph-number">4.1</span></span><span class="comment-syntax"> =</span>
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">Wordings::nonempty</span><span class="plain-syntax">(</span><span class="identifier-syntax">Node::get_text</span><span class="plain-syntax">(</span><span class="identifier-syntax">to_compile</span><span class="plain-syntax">))) {</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">TEMPORARY_TEXT</span><span class="plain-syntax">(</span><span class="identifier-syntax">C</span><span class="plain-syntax">)</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">WRITE_TO</span><span class="plain-syntax">(</span><span class="identifier-syntax">C</span><span class="plain-syntax">, </span><span class="string-syntax">"[%d: "</span><span class="plain-syntax">, </span><span class="identifier-syntax">statement_count</span><span class="plain-syntax">);</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">TranscodeText::comment</span><span class="plain-syntax">(</span><span class="identifier-syntax">C</span><span class="plain-syntax">, </span><span class="identifier-syntax">Node::get_text</span><span class="plain-syntax">(</span><span class="identifier-syntax">to_compile</span><span class="plain-syntax">));</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">WRITE_TO</span><span class="plain-syntax">(</span><span class="identifier-syntax">C</span><span class="plain-syntax">, </span><span class="string-syntax">"]"</span><span class="plain-syntax">);</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">EmitCode::comment</span><span class="plain-syntax">(</span><span class="identifier-syntax">C</span><span class="plain-syntax">);</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">DISCARD_TEXT</span><span class="plain-syntax">(</span><span class="identifier-syntax">C</span><span class="plain-syntax">)</span>
<span class="plain-syntax">    }</span>
</pre>
<ul class="endnotetexts"><li>This code is used in <a href="5-cbal.html#SP4">&#167;4</a>.</li></ul>
<p class="commentary firstcommentary"><a id="SP4_2" class="paragraph-anchor"></a><b>&#167;4.2. </b><span class="named-paragraph-container code-font"><span class="named-paragraph-defn">Compile a location reference for this line</span><span class="named-paragraph-number">4.2</span></span><span class="comment-syntax"> =</span>
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="plain-syntax">    </span><span class="identifier-syntax">source_location</span><span class="plain-syntax"> </span><span class="identifier-syntax">sl</span><span class="plain-syntax"> = </span><span class="identifier-syntax">Wordings::location</span><span class="plain-syntax">(</span><span class="identifier-syntax">Node::get_text</span><span class="plain-syntax">(</span><span class="identifier-syntax">to_compile</span><span class="plain-syntax">));</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">sl</span><span class="plain-syntax">.</span><span class="identifier-syntax">file_of_origin</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">TEMPORARY_TEXT</span><span class="plain-syntax">(</span><span class="identifier-syntax">fname</span><span class="plain-syntax">);</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">WRITE_TO</span><span class="plain-syntax">(</span><span class="identifier-syntax">fname</span><span class="plain-syntax">, </span><span class="string-syntax">"%f"</span><span class="plain-syntax">, </span><span class="identifier-syntax">sl</span><span class="plain-syntax">.</span><span class="identifier-syntax">file_of_origin</span><span class="plain-syntax">-&gt;</span><span class="identifier-syntax">name</span><span class="plain-syntax">);</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">text_provenance</span><span class="plain-syntax"> </span><span class="identifier-syntax">loc</span><span class="plain-syntax"> = </span><span class="identifier-syntax">Provenance::at_file_and_line</span><span class="plain-syntax">(</span><span class="identifier-syntax">fname</span><span class="plain-syntax">, </span><span class="identifier-syntax">sl</span><span class="plain-syntax">.</span><span class="identifier-syntax">line_number</span><span class="plain-syntax">);</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">DISCARD_TEXT</span><span class="plain-syntax">(</span><span class="identifier-syntax">fname</span><span class="plain-syntax">);</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">Str::ne</span><span class="plain-syntax">(</span><span class="identifier-syntax">loc</span><span class="plain-syntax">.</span><span class="identifier-syntax">textual_filename</span><span class="plain-syntax">, </span><span class="identifier-syntax">last_loc</span><span class="plain-syntax">-&gt;</span><span class="identifier-syntax">textual_filename</span><span class="plain-syntax">) || </span><span class="identifier-syntax">loc</span><span class="plain-syntax">.</span><span class="identifier-syntax">line_number</span><span class="plain-syntax"> != </span><span class="identifier-syntax">last_loc</span><span class="plain-syntax">-&gt;</span><span class="identifier-syntax">line_number</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">            *</span><span class="identifier-syntax">last_loc</span><span class="plain-syntax"> = </span><span class="identifier-syntax">loc</span><span class="plain-syntax">;</span>
<span class="plain-syntax">            </span><span class="identifier-syntax">EmitCode::provenance</span><span class="plain-syntax">(</span><span class="identifier-syntax">loc</span><span class="plain-syntax">);</span>
<span class="plain-syntax">        }</span>
<span class="plain-syntax">    }</span>
</pre>
<ul class="endnotetexts"><li>This code is used in <a href="5-cbal.html#SP4">&#167;4</a>.</li></ul>
<p class="commentary firstcommentary"><a id="SP4_3" class="paragraph-anchor"></a><b>&#167;4.3. Head code for lines.</b>We divide the work of compiling the line into "head" code, "midriff" code
and then "tail" code. For the head, there's usually nothing to do, except
for "say" phrases:
</p>

<p class="commentary"><span class="named-paragraph-container code-font"><span class="named-paragraph-defn">Compile the head</span><span class="named-paragraph-number">4.3</span></span><span class="comment-syntax"> =</span>
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">csp</span><span class="plain-syntax"> == </span><span class="identifier-syntax">say_CSP</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">current_sentence</span><span class="plain-syntax"> = </span><span class="identifier-syntax">to_compile</span><span class="plain-syntax">;</span>
<span class="plain-syntax">        </span><span class="named-paragraph-container code-font"><a href="5-cbal.html#SP4_3_1" class="named-paragraph-link"><span class="named-paragraph">Compile a say head</span><span class="named-paragraph-number">4.3.1</span></a></span><span class="plain-syntax">;</span>
<span class="plain-syntax">    }</span>
</pre>
<ul class="endnotetexts"><li>This code is used in <a href="5-cbal.html#SP4">&#167;4</a>.</li></ul>
<p class="commentary firstcommentary"><a id="SP4_3_1" class="paragraph-anchor"></a><b>&#167;4.3.1. </b>"Say" phrases are different, since their invocation lists can contain multiple
things to do (rather than multiple alternatives for one thing to do). We also
need to treat the last of those things differently to the others: if it means
printing literal text ending in sentence-ending punctuation, we need to infer
a newline.
</p>

<p class="commentary"><span class="named-paragraph-container code-font"><span class="named-paragraph-defn">Compile a say head</span><span class="named-paragraph-number">4.3.1</span></span><span class="comment-syntax"> =</span>
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="plain-syntax">    </span><span class="reserved-syntax">for</span><span class="plain-syntax"> (</span><span class="identifier-syntax">parse_node</span><span class="plain-syntax"> *</span><span class="identifier-syntax">say_node</span><span class="plain-syntax"> = </span><span class="identifier-syntax">p</span><span class="plain-syntax">-&gt;</span><span class="identifier-syntax">down</span><span class="plain-syntax">, *</span><span class="identifier-syntax">prev_sn</span><span class="plain-syntax"> = </span><span class="identifier-syntax">NULL</span><span class="plain-syntax">;</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">say_node</span><span class="plain-syntax">;</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">prev_sn</span><span class="plain-syntax"> = </span><span class="identifier-syntax">say_node</span><span class="plain-syntax">, </span><span class="identifier-syntax">say_node</span><span class="plain-syntax"> = </span><span class="identifier-syntax">say_node</span><span class="plain-syntax">-&gt;</span><span class="identifier-syntax">next</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">SParser::parse_say_term</span><span class="plain-syntax">(</span><span class="identifier-syntax">say_node</span><span class="plain-syntax">);</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">parse_node</span><span class="plain-syntax"> *</span><span class="identifier-syntax">inv</span><span class="plain-syntax"> = </span><span class="identifier-syntax">InvocationLists::first_reading</span><span class="plain-syntax">(</span><span class="identifier-syntax">say_node</span><span class="plain-syntax">-&gt;</span><span class="identifier-syntax">down</span><span class="plain-syntax">);</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">inv</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">            </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">prev_sn</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">                </span><span class="reserved-syntax">if</span><span class="plain-syntax"> ((</span><span class="identifier-syntax">Node::get_say_verb</span><span class="plain-syntax">(</span><span class="identifier-syntax">inv</span><span class="plain-syntax">)) ||</span>
<span class="plain-syntax">                    (</span><span class="identifier-syntax">Node::get_say_adjective</span><span class="plain-syntax">(</span><span class="identifier-syntax">inv</span><span class="plain-syntax">)) ||</span>
<span class="plain-syntax">                    ((</span><span class="identifier-syntax">IDTypeData::is_a_say_phrase</span><span class="plain-syntax">(</span><span class="identifier-syntax">Node::get_phrase_invoked</span><span class="plain-syntax">(</span><span class="identifier-syntax">inv</span><span class="plain-syntax">))) &amp;&amp;</span>
<span class="plain-syntax">                        (</span><span class="identifier-syntax">Node::get_phrase_invoked</span><span class="plain-syntax">(</span><span class="identifier-syntax">inv</span><span class="plain-syntax">)-&gt;</span><span class="identifier-syntax">type_data</span><span class="plain-syntax">.</span><span class="identifier-syntax">as_say</span><span class="plain-syntax">.</span><span class="identifier-syntax">say_phrase_running_on</span><span class="plain-syntax">)))</span>
<span class="plain-syntax">                    </span><span class="identifier-syntax">Annotations::write_int</span><span class="plain-syntax">(</span><span class="identifier-syntax">prev_sn</span><span class="plain-syntax">, </span><span class="identifier-syntax">suppress_newlines_ANNOT</span><span class="plain-syntax">, </span><span class="identifier-syntax">TRUE</span><span class="plain-syntax">);</span>
<span class="plain-syntax">            }</span>
<span class="plain-syntax">        }</span>
<span class="plain-syntax">    }</span>
<span class="plain-syntax">    </span><span class="comment-syntax"> warn the paragraph breaker by setting the say__p flag that this will print</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">EmitCode::inv</span><span class="plain-syntax">(</span><span class="identifier-syntax">STORE_BIP</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">EmitCode::down</span><span class="plain-syntax">();</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">EmitCode::ref_iname</span><span class="plain-syntax">(</span><span class="identifier-syntax">K_number</span><span class="plain-syntax">, </span><span class="identifier-syntax">Hierarchy::find</span><span class="plain-syntax">(</span><span class="identifier-syntax">SAY__P_HL</span><span class="plain-syntax">));</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">EmitCode::val_number</span><span class="plain-syntax">(1);</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">EmitCode::up</span><span class="plain-syntax">();</span>
<span class="plain-syntax">    </span><a href="5-cbal.html#SP8" class="function-link"><span class="function-syntax">CompileBlocksAndLines::verify_say_node_list</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">p</span><span class="plain-syntax">-&gt;</span><span class="identifier-syntax">down</span><span class="plain-syntax">);</span>
</pre>
<ul class="endnotetexts"><li>This code is used in <a href="5-cbal.html#SP4_3">&#167;4.3</a>.</li></ul>
<p class="commentary firstcommentary"><a id="SP4_4" class="paragraph-anchor"></a><b>&#167;4.4. Midriff code for lines.</b>The midriff is more work, because several of the control structure phrases
need bespoke handling:
</p>

<p class="commentary"><span class="named-paragraph-container code-font"><span class="named-paragraph-defn">Compile the midriff</span><span class="named-paragraph-number">4.4</span></span><span class="comment-syntax"> =</span>
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">Node::get_type</span><span class="plain-syntax">(</span><span class="identifier-syntax">to_compile</span><span class="plain-syntax">) == </span><span class="identifier-syntax">INVOCATION_LIST_SAY_NT</span><span class="plain-syntax">) </span><span class="named-paragraph-container code-font"><a href="5-cbal.html#SP4_4_1" class="named-paragraph-link"><span class="named-paragraph">Compile a say term midriff</span><span class="named-paragraph-number">4.4.1</span></a></span>
<span class="plain-syntax">    </span><span class="reserved-syntax">else</span><span class="plain-syntax"> </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">csp</span><span class="plain-syntax"> == </span><span class="identifier-syntax">if_CSP</span><span class="plain-syntax">) </span><span class="named-paragraph-container code-font"><a href="5-cbal.html#SP4_4_3" class="named-paragraph-link"><span class="named-paragraph">Compile an if midriff</span><span class="named-paragraph-number">4.4.3</span></a></span>
<span class="plain-syntax">    </span><span class="reserved-syntax">else</span><span class="plain-syntax"> </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">csp</span><span class="plain-syntax"> == </span><span class="identifier-syntax">switch_CSP</span><span class="plain-syntax">) </span><span class="named-paragraph-container code-font"><a href="5-cbal.html#SP4_4_4" class="named-paragraph-link"><span class="named-paragraph">Compile a switch midriff</span><span class="named-paragraph-number">4.4.4</span></a></span>
<span class="plain-syntax">    </span><span class="reserved-syntax">else</span><span class="plain-syntax"> </span><span class="reserved-syntax">if</span><span class="plain-syntax"> ((</span><span class="identifier-syntax">csp</span><span class="plain-syntax"> != </span><span class="identifier-syntax">say_CSP</span><span class="plain-syntax">) &amp;&amp; (</span><span class="identifier-syntax">csp</span><span class="plain-syntax"> != </span><span class="identifier-syntax">instead_CSP</span><span class="plain-syntax">)) {</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="function-syntax">&lt;named-rulebook-outcome&gt;</span><span class="plain-syntax">(</span><span class="identifier-syntax">Node::get_text</span><span class="plain-syntax">(</span><span class="identifier-syntax">to_compile</span><span class="plain-syntax">)))</span>
<span class="plain-syntax">            </span><span class="named-paragraph-container code-font"><a href="5-cbal.html#SP4_4_2" class="named-paragraph-link"><span class="named-paragraph">Compile a named rulebook outline midriff</span><span class="named-paragraph-number">4.4.2</span></a></span>
<span class="plain-syntax">        </span><span class="reserved-syntax">else</span><span class="plain-syntax"> </span><span class="named-paragraph-container code-font"><a href="5-cbal.html#SP4_4_5" class="named-paragraph-link"><span class="named-paragraph">Compile a standard midriff</span><span class="named-paragraph-number">4.4.5</span></a></span><span class="plain-syntax">;</span>
<span class="plain-syntax">    }</span>
</pre>
<ul class="endnotetexts"><li>This code is used in <a href="5-cbal.html#SP4">&#167;4</a>.</li></ul>
<p class="commentary firstcommentary"><a id="SP4_4_1" class="paragraph-anchor"></a><b>&#167;4.4.1. </b><span class="named-paragraph-container code-font"><span class="named-paragraph-defn">Compile a say term midriff</span><span class="named-paragraph-number">4.4.1</span></span><span class="comment-syntax"> =</span>
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="plain-syntax">    </span><span class="reserved-syntax">int</span><span class="plain-syntax"> </span><span class="identifier-syntax">s</span><span class="plain-syntax"> = </span><span class="identifier-syntax">allow_implied_newlines</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">Annotations::read_int</span><span class="plain-syntax">(</span><span class="identifier-syntax">to_compile</span><span class="plain-syntax">, </span><span class="identifier-syntax">suppress_newlines_ANNOT</span><span class="plain-syntax">))</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">allow_implied_newlines</span><span class="plain-syntax"> = </span><span class="identifier-syntax">FALSE</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><a href="5-cbal.html#SP6" class="function-link"><span class="function-syntax">CompileBlocksAndLines::evaluate_invocation</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">to_compile</span><span class="plain-syntax">, </span><span class="identifier-syntax">TRUE</span><span class="plain-syntax">, </span><span class="identifier-syntax">INTER_VOID_VHMODE</span><span class="plain-syntax">,</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">allow_implied_newlines</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">allow_implied_newlines</span><span class="plain-syntax"> = </span><span class="identifier-syntax">s</span><span class="plain-syntax">;</span>
</pre>
<ul class="endnotetexts"><li>This code is used in <a href="5-cbal.html#SP4_4">&#167;4.4</a>.</li></ul>
<p class="commentary firstcommentary"><a id="SP4_4_2" class="paragraph-anchor"></a><b>&#167;4.4.2. </b><span class="named-paragraph-container code-font"><span class="named-paragraph-defn">Compile a named rulebook outline midriff</span><span class="named-paragraph-number">4.4.2</span></span><span class="comment-syntax"> =</span>
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="plain-syntax">    </span><span class="identifier-syntax">current_sentence</span><span class="plain-syntax"> = </span><span class="identifier-syntax">to_compile</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">named_rulebook_outcome</span><span class="plain-syntax"> *</span><span class="identifier-syntax">nrbo</span><span class="plain-syntax"> = </span><span class="function-syntax">&lt;&lt;rp&gt;&gt;</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">id_body</span><span class="plain-syntax"> *</span><span class="identifier-syntax">being_compiled</span><span class="plain-syntax"> = </span><a href="3-fnc.html#SP4" class="function-link"><span class="function-syntax">Functions::defn_being_compiled</span></a><span class="plain-syntax">();</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">being_compiled</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">ImperativeDefinitionFamilies::goes_in_rulebooks</span><span class="plain-syntax">(</span><span class="identifier-syntax">being_compiled</span><span class="plain-syntax">-&gt;</span><span class="identifier-syntax">head_of_defn</span><span class="plain-syntax">)</span>
<span class="plain-syntax">            == </span><span class="identifier-syntax">FALSE</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">            </span><span class="identifier-syntax">Problems::quote_source</span><span class="plain-syntax">(1, </span><span class="identifier-syntax">current_sentence</span><span class="plain-syntax">);</span>
<span class="plain-syntax">            </span><span class="identifier-syntax">Problems::quote_wording</span><span class="plain-syntax">(2, </span><span class="identifier-syntax">Node::get_text</span><span class="plain-syntax">(</span><span class="identifier-syntax">to_compile</span><span class="plain-syntax">));</span>
<span class="plain-syntax">            </span><span class="identifier-syntax">StandardProblems::handmade_problem</span><span class="plain-syntax">(</span><span class="identifier-syntax">Task::syntax_tree</span><span class="plain-syntax">(),</span>
<span class="plain-syntax">                </span><span class="identifier-syntax">_p_</span><span class="plain-syntax">(</span><span class="identifier-syntax">PM_MisplacedRulebookOutcome2</span><span class="plain-syntax">));</span>
<span class="plain-syntax">            </span><span class="identifier-syntax">Problems::issue_problem_segment</span><span class="plain-syntax">(</span>
<span class="plain-syntax">                </span><span class="string-syntax">"You wrote %1, but this is a rulebook outcome which can only be used within "</span>
<span class="plain-syntax">                </span><span class="string-syntax">"rulebooks which recognise it. You've used it in a definition which isn't "</span>
<span class="plain-syntax">                </span><span class="string-syntax">"for use in rulebooks at all, so it must be wrong here."</span><span class="plain-syntax">);</span>
<span class="plain-syntax">            </span><span class="identifier-syntax">Problems::issue_problem_end</span><span class="plain-syntax">();</span>
<span class="plain-syntax">        }</span>
<span class="plain-syntax">    }</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">rulebook</span><span class="plain-syntax"> *</span><span class="identifier-syntax">rb</span><span class="plain-syntax"> = </span><span class="identifier-syntax">NULL</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">RuleFamily::outcome_restrictions_waived</span><span class="plain-syntax">() == </span><span class="identifier-syntax">FALSE</span><span class="plain-syntax">)</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">rb</span><span class="plain-syntax"> = </span><span class="identifier-syntax">FocusAndOutcome::rulebook_not_supporting</span><span class="plain-syntax">(</span><span class="identifier-syntax">nrbo</span><span class="plain-syntax">, </span><a href="3-fnc.html#SP4" class="function-link"><span class="function-syntax">Functions::defn_being_compiled</span></a><span class="plain-syntax">());</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">rb</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">Problems::quote_source</span><span class="plain-syntax">(1, </span><span class="identifier-syntax">current_sentence</span><span class="plain-syntax">);</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">Problems::quote_wording</span><span class="plain-syntax">(2, </span><span class="identifier-syntax">Node::get_text</span><span class="plain-syntax">(</span><span class="identifier-syntax">to_compile</span><span class="plain-syntax">));</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">Problems::quote_wording</span><span class="plain-syntax">(3, </span><span class="identifier-syntax">rb</span><span class="plain-syntax">-&gt;</span><span class="identifier-syntax">primary_name</span><span class="plain-syntax">);</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">StandardProblems::handmade_problem</span><span class="plain-syntax">(</span><span class="identifier-syntax">Task::syntax_tree</span><span class="plain-syntax">(),</span>
<span class="plain-syntax">            </span><span class="identifier-syntax">_p_</span><span class="plain-syntax">(</span><span class="identifier-syntax">PM_MisplacedRulebookOutcome</span><span class="plain-syntax">));</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">Problems::issue_problem_segment</span><span class="plain-syntax">(</span>
<span class="plain-syntax">            </span><span class="string-syntax">"You wrote %1, but this is a rulebook outcome which can only be used within "</span>
<span class="plain-syntax">            </span><span class="string-syntax">"rulebooks which recognise it. You've used it in a rule which has to be listed "</span>
<span class="plain-syntax">            </span><span class="string-syntax">"in the '%3' rulebook, where '%2' doesn't have a meaning."</span><span class="plain-syntax">);</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">Problems::issue_problem_end</span><span class="plain-syntax">();</span>
<span class="plain-syntax">    }</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">RTRulebooks::compile_outcome</span><span class="plain-syntax">(</span><span class="identifier-syntax">nrbo</span><span class="plain-syntax">);</span>
</pre>
<ul class="endnotetexts"><li>This code is used in <a href="5-cbal.html#SP4_4">&#167;4.4</a>.</li></ul>
<p class="commentary firstcommentary"><a id="SP4_4_3" class="paragraph-anchor"></a><b>&#167;4.4.3. </b>When an "if" node has two children, they are the condition to test and then
the code block of what to execute if the condition is true:
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="plain-syntax">        </span><span class="identifier-syntax">CODE_BLOCK_NT</span><span class="plain-syntax"> {</span><span class="identifier-syntax">control</span><span class="plain-syntax"> </span><span class="identifier-syntax">structure:</span><span class="plain-syntax"> </span><span class="identifier-syntax">IF</span><span class="plain-syntax">}</span>
<span class="plain-syntax">            </span><span class="identifier-syntax">INVOCATION_LIST_NT</span><span class="character-syntax">'if ...'</span><span class="plain-syntax"> {</span><span class="identifier-syntax">colon_block_command</span><span class="plain-syntax">} {</span><span class="identifier-syntax">indent:</span><span class="plain-syntax"> </span><span class="constant-syntax">1</span><span class="plain-syntax">}</span>
<span class="plain-syntax">            </span><span class="identifier-syntax">CODE_BLOCK_NT</span>
<span class="plain-syntax">                ...</span>
</pre>
<p class="commentary">When it has three children, the extra block is what to execute if the condition
is false:
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="plain-syntax">        </span><span class="identifier-syntax">CODE_BLOCK_NT</span><span class="plain-syntax"> {</span><span class="identifier-syntax">control</span><span class="plain-syntax"> </span><span class="identifier-syntax">structure:</span><span class="plain-syntax"> </span><span class="identifier-syntax">IF</span><span class="plain-syntax">}</span>
<span class="plain-syntax">            </span><span class="identifier-syntax">INVOCATION_LIST_NT</span><span class="character-syntax">'if ...'</span><span class="plain-syntax"> {</span><span class="identifier-syntax">colon_block_command</span><span class="plain-syntax">} {</span><span class="identifier-syntax">indent:</span><span class="plain-syntax"> </span><span class="constant-syntax">1</span><span class="plain-syntax">}</span>
<span class="plain-syntax">            </span><span class="identifier-syntax">CODE_BLOCK_NT</span>
<span class="plain-syntax">                ...</span>
<span class="plain-syntax">            </span><span class="identifier-syntax">CODE_BLOCK_NT</span><span class="character-syntax">'otherwise'</span><span class="plain-syntax"> {</span><span class="identifier-syntax">colon_block_command</span><span class="plain-syntax">} {</span><span class="identifier-syntax">indent:</span><span class="plain-syntax"> </span><span class="constant-syntax">1</span><span class="plain-syntax">} {</span><span class="identifier-syntax">control</span><span class="plain-syntax"> </span><span class="identifier-syntax">structure:</span><span class="plain-syntax"> </span><span class="identifier-syntax">O</span><span class="plain-syntax">}</span>
<span class="plain-syntax">                ...</span>
</pre>
<p class="commentary"><span class="named-paragraph-container code-font"><span class="named-paragraph-defn">Compile an if midriff</span><span class="named-paragraph-number">4.4.3</span></span><span class="comment-syntax"> =</span>
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">p</span><span class="plain-syntax">-&gt;</span><span class="identifier-syntax">down</span><span class="plain-syntax">-&gt;</span><span class="identifier-syntax">next</span><span class="plain-syntax">-&gt;</span><span class="identifier-syntax">next</span><span class="plain-syntax">) </span><span class="identifier-syntax">EmitCode::inv</span><span class="plain-syntax">(</span><span class="identifier-syntax">IFELSE_BIP</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">else</span><span class="plain-syntax"> </span><span class="identifier-syntax">EmitCode::inv</span><span class="plain-syntax">(</span><span class="identifier-syntax">IF_BIP</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">EmitCode::down</span><span class="plain-syntax">();</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">current_sentence</span><span class="plain-syntax"> = </span><span class="identifier-syntax">to_compile</span><span class="plain-syntax">;</span>
<span class="plain-syntax">        </span><a href="5-cbal.html#SP6" class="function-link"><span class="function-syntax">CompileBlocksAndLines::evaluate_invocation</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">to_compile</span><span class="plain-syntax">, </span><span class="identifier-syntax">FALSE</span><span class="plain-syntax">, </span><span class="identifier-syntax">INTER_VAL_VHMODE</span><span class="plain-syntax">,</span>
<span class="plain-syntax">            </span><span class="identifier-syntax">allow_implied_newlines</span><span class="plain-syntax">);</span>

<span class="plain-syntax">        </span><span class="identifier-syntax">EmitCode::code</span><span class="plain-syntax">();</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">EmitCode::down</span><span class="plain-syntax">();</span>
<span class="plain-syntax">            </span><a href="3-cb.html#SP11" class="function-link"><span class="function-syntax">CodeBlocks::open_code_block</span></a><span class="plain-syntax">();</span>
<span class="plain-syntax">            </span><span class="identifier-syntax">statement_count</span><span class="plain-syntax"> = </span><a href="5-cbal.html#SP2" class="function-link"><span class="function-syntax">CompileBlocksAndLines::code_block</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">statement_count</span><span class="plain-syntax">,</span>
<span class="plain-syntax">                </span><span class="identifier-syntax">p</span><span class="plain-syntax">-&gt;</span><span class="identifier-syntax">down</span><span class="plain-syntax">-&gt;</span><span class="identifier-syntax">next</span><span class="plain-syntax">, </span><span class="identifier-syntax">FALSE</span><span class="plain-syntax">, </span><span class="identifier-syntax">allow_implied_newlines</span><span class="plain-syntax">, </span><span class="identifier-syntax">last_loc</span><span class="plain-syntax">);</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">p</span><span class="plain-syntax">-&gt;</span><span class="identifier-syntax">down</span><span class="plain-syntax">-&gt;</span><span class="identifier-syntax">next</span><span class="plain-syntax">-&gt;</span><span class="identifier-syntax">next</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">EmitCode::up</span><span class="plain-syntax">();</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">EmitCode::code</span><span class="plain-syntax">();</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">EmitCode::down</span><span class="plain-syntax">();</span>
<span class="plain-syntax">            </span><a href="3-cb.html#SP12" class="function-link"><span class="function-syntax">CodeBlocks::divide_code_block</span></a><span class="plain-syntax">();</span>
<span class="plain-syntax">            </span><span class="identifier-syntax">statement_count</span><span class="plain-syntax"> = </span><a href="5-cbal.html#SP2" class="function-link"><span class="function-syntax">CompileBlocksAndLines::code_block</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">statement_count</span><span class="plain-syntax">,</span>
<span class="plain-syntax">                </span><span class="identifier-syntax">p</span><span class="plain-syntax">-&gt;</span><span class="identifier-syntax">down</span><span class="plain-syntax">-&gt;</span><span class="identifier-syntax">next</span><span class="plain-syntax">-&gt;</span><span class="identifier-syntax">next</span><span class="plain-syntax">, </span><span class="identifier-syntax">FALSE</span><span class="plain-syntax">, </span><span class="identifier-syntax">allow_implied_newlines</span><span class="plain-syntax">, </span><span class="identifier-syntax">last_loc</span><span class="plain-syntax">);</span>
<span class="plain-syntax">        }</span>
<span class="plain-syntax">            </span><a href="3-cb.html#SP13" class="function-link"><span class="function-syntax">CodeBlocks::close_code_block</span></a><span class="plain-syntax">();</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">EmitCode::up</span><span class="plain-syntax">();</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">EmitCode::up</span><span class="plain-syntax">();</span>
</pre>
<ul class="endnotetexts"><li>This code is used in <a href="5-cbal.html#SP4_4">&#167;4.4</a>.</li></ul>
<p class="commentary firstcommentary"><a id="SP4_4_4" class="paragraph-anchor"></a><b>&#167;4.4.4. </b>Switches, like <span class="extract"><span class="extract-syntax">switch</span></span> in C, offer code to execute in different cases
depending on the "switch value". How efficiently this can be done depends
on the kind of that value.
</p>

<p class="commentary">The Inter VM offers an efficient way to provide switches for single-word
values, using <span class="extract"><span class="extract-syntax">SWITCH_BIP</span></span>. But that only works if equality between two
values <span class="extract"><span class="extract-syntax">V1</span></span> and <span class="extract"><span class="extract-syntax">V2</span></span> can be tested by <span class="extract"><span class="extract-syntax">V1 == V2</span></span>. For word-valued kinds
like <span class="extract"><span class="extract-syntax">K_number</span></span>, that's fine, but not for kinds whose values are stored
in allocated blocks of memory, like <span class="extract"><span class="extract-syntax">K_text</span></span>: <span class="extract"><span class="extract-syntax">V1</span></span> and <span class="extract"><span class="extract-syntax">V2</span></span> may be
pointers to different blocks of data, so that <span class="extract"><span class="extract-syntax">V1 != V2</span></span>, even though
both blocks might hold the word "doubloon" so that the values are in fact
equal.
</p>

<p class="commentary">So we have to provide two completely different implementations. The harder
case, involving pointers to block values, is called "pointery"; the other
one is the "non-pointery" case.
</p>

<p class="commentary"><span class="named-paragraph-container code-font"><span class="named-paragraph-defn">Compile a switch midriff</span><span class="named-paragraph-number">4.4.4</span></span><span class="comment-syntax"> =</span>
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="plain-syntax">    </span><span class="identifier-syntax">current_sentence</span><span class="plain-syntax"> = </span><span class="identifier-syntax">to_compile</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><a href="5-cbal.html#SP6" class="function-link"><span class="function-syntax">CompileBlocksAndLines::evaluate_invocation</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">to_compile</span><span class="plain-syntax">, </span><span class="identifier-syntax">FALSE</span><span class="plain-syntax">, </span><span class="identifier-syntax">INTER_VOID_VHMODE</span><span class="plain-syntax">,</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">allow_implied_newlines</span><span class="plain-syntax">);</span>

<span class="plain-syntax">    </span><a href="3-cb.html#SP11" class="function-link"><span class="function-syntax">CodeBlocks::open_code_block</span></a><span class="plain-syntax">();</span>

<span class="plain-syntax">    </span><span class="identifier-syntax">parse_node</span><span class="plain-syntax"> *</span><span class="identifier-syntax">switch_val</span><span class="plain-syntax"> = </span><a href="3-cb.html#SP15" class="function-link"><span class="function-syntax">CodeBlocks::switch_value</span></a><span class="plain-syntax">();</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">kind</span><span class="plain-syntax"> *</span><span class="identifier-syntax">switch_kind</span><span class="plain-syntax"> = </span><span class="identifier-syntax">Specifications::to_kind</span><span class="plain-syntax">(</span><span class="identifier-syntax">switch_val</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">switch_val</span><span class="plain-syntax"> == </span><span class="identifier-syntax">NULL</span><span class="plain-syntax">) </span><span class="identifier-syntax">internal_error</span><span class="plain-syntax">(</span><span class="string-syntax">"no switch value"</span><span class="plain-syntax">);</span>

<span class="plain-syntax">    </span><span class="reserved-syntax">int</span><span class="plain-syntax"> </span><span class="identifier-syntax">downs</span><span class="plain-syntax"> = </span><span class="constant-syntax">0</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">local_variable</span><span class="plain-syntax"> *</span><span class="identifier-syntax">sw_lv</span><span class="plain-syntax"> = </span><span class="identifier-syntax">NULL</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">inter_symbol</span><span class="plain-syntax"> *</span><span class="identifier-syntax">sw_v</span><span class="plain-syntax"> = </span><span class="identifier-syntax">NULL</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">int</span><span class="plain-syntax"> </span><span class="identifier-syntax">pointery</span><span class="plain-syntax"> = </span><span class="identifier-syntax">FALSE</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">Kinds::Behaviour::uses_block_values</span><span class="plain-syntax">(</span><span class="identifier-syntax">switch_kind</span><span class="plain-syntax">)) </span><span class="identifier-syntax">pointery</span><span class="plain-syntax"> = </span><span class="identifier-syntax">TRUE</span><span class="plain-syntax">;</span>

<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">pointery</span><span class="plain-syntax">) </span><span class="named-paragraph-container code-font"><a href="5-cbal.html#SP4_4_4_2" class="named-paragraph-link"><span class="named-paragraph">Begin a pointery switch</span><span class="named-paragraph-number">4.4.4.2</span></a></span>
<span class="plain-syntax">    </span><span class="reserved-syntax">else</span><span class="plain-syntax"> </span><span class="named-paragraph-container code-font"><a href="5-cbal.html#SP4_4_4_5" class="named-paragraph-link"><span class="named-paragraph">Begin a non-pointery switch</span><span class="named-paragraph-number">4.4.4.5</span></a></span><span class="plain-syntax">;</span>

<span class="plain-syntax">    </span><span class="reserved-syntax">int</span><span class="plain-syntax"> </span><span class="identifier-syntax">c</span><span class="plain-syntax"> = </span><span class="constant-syntax">0</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">for</span><span class="plain-syntax"> (</span><span class="identifier-syntax">parse_node</span><span class="plain-syntax"> *</span><span class="identifier-syntax">ow_node</span><span class="plain-syntax"> = </span><span class="identifier-syntax">p</span><span class="plain-syntax">-&gt;</span><span class="identifier-syntax">down</span><span class="plain-syntax">-&gt;</span><span class="identifier-syntax">next</span><span class="plain-syntax">-&gt;</span><span class="identifier-syntax">next</span><span class="plain-syntax">; </span><span class="identifier-syntax">ow_node</span><span class="plain-syntax">; </span><span class="identifier-syntax">ow_node</span><span class="plain-syntax"> = </span><span class="identifier-syntax">ow_node</span><span class="plain-syntax">-&gt;</span><span class="identifier-syntax">next</span><span class="plain-syntax">, </span><span class="identifier-syntax">c</span><span class="plain-syntax">++) {</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">current_sentence</span><span class="plain-syntax"> = </span><span class="identifier-syntax">ow_node</span><span class="plain-syntax">;</span>
<span class="plain-syntax">        </span><a href="3-cb.html#SP12" class="function-link"><span class="function-syntax">CodeBlocks::divide_code_block</span></a><span class="plain-syntax">();</span>

<span class="plain-syntax">        </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">Node::get_control_structure_used</span><span class="plain-syntax">(</span><span class="identifier-syntax">ow_node</span><span class="plain-syntax">) == </span><span class="identifier-syntax">default_case_CSP</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">            </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">pointery</span><span class="plain-syntax">) </span><span class="named-paragraph-container code-font"><a href="5-cbal.html#SP4_4_4_3" class="named-paragraph-link"><span class="named-paragraph">Handle a pointery default</span><span class="named-paragraph-number">4.4.4.3</span></a></span>
<span class="plain-syntax">            </span><span class="reserved-syntax">else</span><span class="plain-syntax"> </span><span class="named-paragraph-container code-font"><a href="5-cbal.html#SP4_4_4_6" class="named-paragraph-link"><span class="named-paragraph">Handle a non-pointery default</span><span class="named-paragraph-number">4.4.4.6</span></a></span><span class="plain-syntax">;</span>
<span class="plain-syntax">        } </span><span class="reserved-syntax">else</span><span class="plain-syntax"> {</span>
<span class="plain-syntax">            </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="function-syntax">&lt;s-type-expression-or-value&gt;</span><span class="plain-syntax">(</span><span class="identifier-syntax">Node::get_text</span><span class="plain-syntax">(</span><span class="identifier-syntax">ow_node</span><span class="plain-syntax">))) {</span>
<span class="plain-syntax">                </span><span class="identifier-syntax">parse_node</span><span class="plain-syntax"> *</span><span class="identifier-syntax">case_spec</span><span class="plain-syntax"> = </span><span class="function-syntax">&lt;&lt;rp&gt;&gt;</span><span class="plain-syntax">;</span>
<span class="plain-syntax">                </span><span class="identifier-syntax">case_spec</span><span class="plain-syntax"> = </span><span class="identifier-syntax">NonlocalVariables::substitute_constants</span><span class="plain-syntax">(</span><span class="identifier-syntax">case_spec</span><span class="plain-syntax">);</span>
<span class="plain-syntax">                </span><span class="identifier-syntax">Node::set_evaluation</span><span class="plain-syntax">(</span><span class="identifier-syntax">ow_node</span><span class="plain-syntax">, </span><span class="identifier-syntax">case_spec</span><span class="plain-syntax">);</span>
<span class="plain-syntax">                </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">Dash::check_value</span><span class="plain-syntax">(</span><span class="identifier-syntax">case_spec</span><span class="plain-syntax">, </span><span class="identifier-syntax">NULL</span><span class="plain-syntax">) != </span><span class="identifier-syntax">NEVER_MATCH</span><span class="plain-syntax">)</span>
<span class="plain-syntax">                    </span><span class="named-paragraph-container code-font"><a href="5-cbal.html#SP4_4_4_1" class="named-paragraph-link"><span class="named-paragraph">Handle a general case</span><span class="named-paragraph-number">4.4.4.1</span></a></span>
<span class="plain-syntax">                </span><span class="reserved-syntax">else</span>
<span class="plain-syntax">                    </span><span class="named-paragraph-container code-font"><a href="5-cbal.html#SP4_4_4_9" class="named-paragraph-link"><span class="named-paragraph">Issue problem message for unknown case value</span><span class="named-paragraph-number">4.4.4.9</span></a></span><span class="plain-syntax">;</span>
<span class="plain-syntax">            } </span><span class="reserved-syntax">else</span><span class="plain-syntax"> {</span>
<span class="plain-syntax">                </span><span class="named-paragraph-container code-font"><a href="5-cbal.html#SP4_4_4_9" class="named-paragraph-link"><span class="named-paragraph">Issue problem message for unknown case value</span><span class="named-paragraph-number">4.4.4.9</span></a></span><span class="plain-syntax">;</span>
<span class="plain-syntax">            }</span>
<span class="plain-syntax">        }</span>
<span class="plain-syntax">    }</span>

<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">pointery</span><span class="plain-syntax">) </span><span class="named-paragraph-container code-font"><a href="5-cbal.html#SP4_4_4_4" class="named-paragraph-link"><span class="named-paragraph">End a pointery switch</span><span class="named-paragraph-number">4.4.4.4</span></a></span>
<span class="plain-syntax">    </span><span class="reserved-syntax">else</span><span class="plain-syntax"> </span><span class="named-paragraph-container code-font"><a href="5-cbal.html#SP4_4_4_7" class="named-paragraph-link"><span class="named-paragraph">End a non-pointery switch</span><span class="named-paragraph-number">4.4.4.7</span></a></span><span class="plain-syntax">;</span>

<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">problem_count</span><span class="plain-syntax"> == </span><span class="constant-syntax">0</span><span class="plain-syntax">) </span><span class="named-paragraph-container code-font"><a href="5-cbal.html#SP4_4_4_8" class="named-paragraph-link"><span class="named-paragraph">Test for duplicate cases</span><span class="named-paragraph-number">4.4.4.8</span></a></span><span class="plain-syntax">;</span>
</pre>
<ul class="endnotetexts"><li>This code is used in <a href="5-cbal.html#SP4_4">&#167;4.4</a>.</li></ul>
<p class="commentary firstcommentary"><a id="SP4_4_4_1" class="paragraph-anchor"></a><b>&#167;4.4.4.1. </b><span class="named-paragraph-container code-font"><span class="named-paragraph-defn">Handle a general case</span><span class="named-paragraph-number">4.4.4.1</span></span><span class="comment-syntax"> =</span>
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="plain-syntax">    </span><span class="identifier-syntax">kind</span><span class="plain-syntax"> *</span><span class="identifier-syntax">case_kind</span><span class="plain-syntax"> = </span><span class="identifier-syntax">Specifications::to_kind</span><span class="plain-syntax">(</span><span class="identifier-syntax">case_spec</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">instance</span><span class="plain-syntax"> *</span><span class="identifier-syntax">I</span><span class="plain-syntax"> = </span><span class="identifier-syntax">Rvalues::to_object_instance</span><span class="plain-syntax">(</span><span class="identifier-syntax">case_spec</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">I</span><span class="plain-syntax">) </span><span class="identifier-syntax">case_kind</span><span class="plain-syntax"> = </span><span class="identifier-syntax">Instances::to_kind</span><span class="plain-syntax">(</span><span class="identifier-syntax">I</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">LOGIF</span><span class="plain-syntax">(</span><span class="identifier-syntax">MATCHING</span><span class="plain-syntax">, </span><span class="string-syntax">"(h.3) switch kind is %u, case kind is %u\n"</span><span class="plain-syntax">, </span><span class="identifier-syntax">switch_kind</span><span class="plain-syntax">, </span><span class="identifier-syntax">case_kind</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> ((</span><span class="identifier-syntax">Node::get_kind_of_value</span><span class="plain-syntax">(</span><span class="identifier-syntax">case_spec</span><span class="plain-syntax">) == </span><span class="identifier-syntax">NULL</span><span class="plain-syntax">) &amp;&amp; (</span><span class="identifier-syntax">I</span><span class="plain-syntax"> == </span><span class="identifier-syntax">NULL</span><span class="plain-syntax">)) {</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">Problems::quote_source</span><span class="plain-syntax">(1, </span><span class="identifier-syntax">current_sentence</span><span class="plain-syntax">);</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">Problems::quote_kind</span><span class="plain-syntax">(2, </span><span class="identifier-syntax">switch_kind</span><span class="plain-syntax">);</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">StandardProblems::handmade_problem</span><span class="plain-syntax">(</span><span class="identifier-syntax">Task::syntax_tree</span><span class="plain-syntax">(), </span><span class="identifier-syntax">_p_</span><span class="plain-syntax">(</span><span class="identifier-syntax">PM_CaseValueNonConstant</span><span class="plain-syntax">));</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">Problems::issue_problem_segment</span><span class="plain-syntax">(</span>
<span class="plain-syntax">            </span><span class="string-syntax">"The case %1 is required to be a constant value, rather than "</span>
<span class="plain-syntax">            </span><span class="string-syntax">"something which has different values at different times: "</span>
<span class="plain-syntax">            </span><span class="string-syntax">"specifically, it has to be %2."</span><span class="plain-syntax">);</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">Problems::issue_problem_end</span><span class="plain-syntax">();</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">case_spec</span><span class="plain-syntax"> = </span><span class="identifier-syntax">Rvalues::new_nothing_object_constant</span><span class="plain-syntax">();</span>
<span class="plain-syntax">    } </span><span class="reserved-syntax">else</span><span class="plain-syntax"> </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">Kinds::compatible</span><span class="plain-syntax">(</span><span class="identifier-syntax">case_kind</span><span class="plain-syntax">, </span><span class="identifier-syntax">switch_kind</span><span class="plain-syntax">) != </span><span class="identifier-syntax">ALWAYS_MATCH</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">Problems::quote_source</span><span class="plain-syntax">(1, </span><span class="identifier-syntax">current_sentence</span><span class="plain-syntax">);</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">Problems::quote_kind</span><span class="plain-syntax">(2, </span><span class="identifier-syntax">case_kind</span><span class="plain-syntax">);</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">Problems::quote_kind</span><span class="plain-syntax">(3, </span><span class="identifier-syntax">switch_kind</span><span class="plain-syntax">);</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">StandardProblems::handmade_problem</span><span class="plain-syntax">(</span><span class="identifier-syntax">Task::syntax_tree</span><span class="plain-syntax">(), </span><span class="identifier-syntax">_p_</span><span class="plain-syntax">(</span><span class="identifier-syntax">PM_CaseValueMismatch</span><span class="plain-syntax">));</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">Problems::issue_problem_segment</span><span class="plain-syntax">(</span>
<span class="plain-syntax">            </span><span class="string-syntax">"The case %1 has the wrong kind of value for the possibilities "</span>
<span class="plain-syntax">            </span><span class="string-syntax">"being chosen from: %2 instead of %3."</span><span class="plain-syntax">);</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">Problems::issue_problem_end</span><span class="plain-syntax">();</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">case_spec</span><span class="plain-syntax"> = </span><span class="identifier-syntax">Rvalues::new_nothing_object_constant</span><span class="plain-syntax">();</span>
<span class="plain-syntax">    } </span><span class="reserved-syntax">else</span><span class="plain-syntax"> {</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">pointery</span><span class="plain-syntax">) </span><span class="named-paragraph-container code-font"><a href="5-cbal.html#SP4_4_4_1_1" class="named-paragraph-link"><span class="named-paragraph">Handle a pointery case</span><span class="named-paragraph-number">4.4.4.1.1</span></a></span>
<span class="plain-syntax">        </span><span class="reserved-syntax">else</span><span class="plain-syntax"> </span><span class="named-paragraph-container code-font"><a href="5-cbal.html#SP4_4_4_1_2" class="named-paragraph-link"><span class="named-paragraph">Handle a non-pointery case</span><span class="named-paragraph-number">4.4.4.1.2</span></a></span><span class="plain-syntax">;</span>
<span class="plain-syntax">    }</span>
</pre>
<ul class="endnotetexts"><li>This code is used in <a href="5-cbal.html#SP4_4_4">&#167;4.4.4</a>.</li></ul>
<p class="commentary firstcommentary"><a id="SP4_4_4_2" class="paragraph-anchor"></a><b>&#167;4.4.4.2. </b>Okay, so here's the code for a pointery switch. We generate something like this:
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="plain-syntax">    </span><span class="identifier-syntax">sw_v</span><span class="plain-syntax"> = ... </span><span class="reserved-syntax">switch</span><span class="plain-syntax"> </span><span class="identifier-syntax">value</span><span class="plain-syntax"> ...</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">Equals</span><span class="plain-syntax">(</span><span class="identifier-syntax">sw_v</span><span class="plain-syntax">, </span><span class="identifier-syntax">v1</span><span class="plain-syntax">)) {</span>
<span class="plain-syntax">        ... </span><span class="reserved-syntax">case</span><span class="plain-syntax"> </span><span class="reserved-syntax">for</span><span class="plain-syntax"> </span><span class="identifier-syntax">v1</span><span class="plain-syntax"> ...</span>
<span class="plain-syntax">    } </span><span class="reserved-syntax">else</span><span class="plain-syntax"> {</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">Equals</span><span class="plain-syntax">(</span><span class="identifier-syntax">sw_v</span><span class="plain-syntax">, </span><span class="identifier-syntax">v2</span><span class="plain-syntax">)) {</span>
<span class="plain-syntax">            ... </span><span class="reserved-syntax">case</span><span class="plain-syntax"> </span><span class="reserved-syntax">for</span><span class="plain-syntax"> </span><span class="identifier-syntax">v2</span><span class="plain-syntax"> ...</span>
<span class="plain-syntax">        } </span><span class="reserved-syntax">else</span><span class="plain-syntax"> {</span>
<span class="plain-syntax">            ... </span><span class="reserved-syntax">default</span><span class="plain-syntax"> </span><span class="reserved-syntax">case</span><span class="plain-syntax"> ...</span>
<span class="plain-syntax">        }</span>
<span class="plain-syntax">    }</span>
</pre>
<p class="commentary">We begin by ensuring that the function has a scratch local variable called <span class="extract"><span class="extract-syntax">sw_v</span></span>,
and store the switch value in it. We need not use <span class="extract"><span class="extract-syntax">CopyPV</span></span> to make an
independent copy, since <span class="extract"><span class="extract-syntax">sw_v</span></span> will be read-only: we can just copy the address of
the data into <span class="extract"><span class="extract-syntax">sw_v</span></span> with a single <span class="extract"><span class="extract-syntax">STORE_BIP</span></span> instruction, which is much faster.
</p>

<p class="commentary"><span class="named-paragraph-container code-font"><span class="named-paragraph-defn">Begin a pointery switch</span><span class="named-paragraph-number">4.4.4.2</span></span><span class="comment-syntax"> =</span>
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="plain-syntax">    </span><span class="identifier-syntax">sw_lv</span><span class="plain-syntax"> = </span><a href="3-lv.html#SP11" class="function-link"><span class="function-syntax">LocalVariables::add_switch_value</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">K_value</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">sw_v</span><span class="plain-syntax"> = </span><a href="3-lv.html#SP1" class="function-link"><span class="function-syntax">LocalVariables::declare</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">sw_lv</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">EmitCode::inv</span><span class="plain-syntax">(</span><span class="identifier-syntax">STORE_BIP</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">EmitCode::down</span><span class="plain-syntax">();</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">EmitCode::ref_symbol</span><span class="plain-syntax">(</span><span class="identifier-syntax">K_value</span><span class="plain-syntax">, </span><span class="identifier-syntax">sw_v</span><span class="plain-syntax">);</span>
<span class="plain-syntax">        </span><a href="2-cv.html#SP5" class="function-link"><span class="function-syntax">CompileValues::to_code_val_of_kind</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">switch_val</span><span class="plain-syntax">, </span><span class="identifier-syntax">switch_kind</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">EmitCode::up</span><span class="plain-syntax">();</span>
</pre>
<ul class="endnotetexts"><li>This code is used in <a href="5-cbal.html#SP4_4_4">&#167;4.4.4</a>.</li></ul>
<p class="commentary firstcommentary"><a id="SP4_4_4_1_1" class="paragraph-anchor"></a><b>&#167;4.4.4.1.1. </b>Now we handle the switch case for what to do when <span class="extract"><span class="extract-syntax">sw_v</span></span> is <span class="extract"><span class="extract-syntax">case_spec</span></span>. The count
of <span class="extract"><span class="extract-syntax">downs</span></span> is how many times we have called <span class="extract"><span class="extract-syntax">Produce::down</span></span>.
</p>

<p class="commentary"><span class="named-paragraph-container code-font"><span class="named-paragraph-defn">Handle a pointery case</span><span class="named-paragraph-number">4.4.4.1.1</span></span><span class="comment-syntax"> =</span>
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="plain-syntax">    </span><span class="reserved-syntax">int</span><span class="plain-syntax"> </span><span class="identifier-syntax">final_flag</span><span class="plain-syntax"> = </span><span class="identifier-syntax">FALSE</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">ow_node</span><span class="plain-syntax">-&gt;</span><span class="identifier-syntax">next</span><span class="plain-syntax"> == </span><span class="identifier-syntax">NULL</span><span class="plain-syntax">) </span><span class="identifier-syntax">final_flag</span><span class="plain-syntax"> = </span><span class="identifier-syntax">TRUE</span><span class="plain-syntax">;</span>

<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">final_flag</span><span class="plain-syntax">) </span><span class="identifier-syntax">EmitCode::inv</span><span class="plain-syntax">(</span><span class="identifier-syntax">IF_BIP</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">else</span><span class="plain-syntax"> </span><span class="identifier-syntax">EmitCode::inv</span><span class="plain-syntax">(</span><span class="identifier-syntax">IFELSE_BIP</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">EmitCode::down</span><span class="plain-syntax">();</span>
<span class="plain-syntax">        </span><a href="3-lv.html#SP25" class="function-link"><span class="function-syntax">LocalVariables::set_kind</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">sw_lv</span><span class="plain-syntax">, </span><span class="identifier-syntax">switch_kind</span><span class="plain-syntax">);</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">parse_node</span><span class="plain-syntax"> *</span><span class="identifier-syntax">sw_v</span><span class="plain-syntax"> = </span><span class="identifier-syntax">Lvalues::new_LOCAL_VARIABLE</span><span class="plain-syntax">(</span><span class="identifier-syntax">EMPTY_WORDING</span><span class="plain-syntax">, </span><span class="identifier-syntax">sw_lv</span><span class="plain-syntax">);</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">pcalc_prop</span><span class="plain-syntax"> *</span><span class="identifier-syntax">prop</span><span class="plain-syntax"> = </span><span class="identifier-syntax">Propositions::Abstract::to_set_relation</span><span class="plain-syntax">(</span>
<span class="plain-syntax">            </span><span class="identifier-syntax">R_equality</span><span class="plain-syntax">, </span><span class="identifier-syntax">NULL</span><span class="plain-syntax">, </span><span class="identifier-syntax">sw_v</span><span class="plain-syntax">, </span><span class="identifier-syntax">NULL</span><span class="plain-syntax">, </span><span class="identifier-syntax">case_spec</span><span class="plain-syntax">);</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">TypecheckPropositions::type_check</span><span class="plain-syntax">(</span><span class="identifier-syntax">prop</span><span class="plain-syntax">,</span>
<span class="plain-syntax">            </span><span class="identifier-syntax">TypecheckPropositions::tc_no_problem_reporting</span><span class="plain-syntax">());</span>
<span class="plain-syntax">        </span><a href="4-cp.html#SP1" class="function-link"><span class="function-syntax">CompilePropositions::to_test_as_condition</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">NULL</span><span class="plain-syntax">, </span><span class="identifier-syntax">prop</span><span class="plain-syntax">);</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">EmitCode::code</span><span class="plain-syntax">();</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">EmitCode::down</span><span class="plain-syntax">();</span>
<span class="plain-syntax">            </span><span class="identifier-syntax">statement_count</span><span class="plain-syntax"> = </span><a href="5-cbal.html#SP2" class="function-link"><span class="function-syntax">CompileBlocksAndLines::code_block</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">statement_count</span><span class="plain-syntax">,</span>
<span class="plain-syntax">                </span><span class="identifier-syntax">ow_node</span><span class="plain-syntax">, </span><span class="identifier-syntax">FALSE</span><span class="plain-syntax">, </span><span class="identifier-syntax">allow_implied_newlines</span><span class="plain-syntax">, </span><span class="identifier-syntax">last_loc</span><span class="plain-syntax">);</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">final_flag</span><span class="plain-syntax"> == </span><span class="identifier-syntax">FALSE</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">            </span><span class="identifier-syntax">EmitCode::up</span><span class="plain-syntax">();</span>
<span class="plain-syntax">            </span><span class="identifier-syntax">EmitCode::code</span><span class="plain-syntax">();</span>
<span class="plain-syntax">            </span><span class="identifier-syntax">EmitCode::down</span><span class="plain-syntax">();</span>
<span class="plain-syntax">        }</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">downs</span><span class="plain-syntax"> += </span><span class="constant-syntax">2</span><span class="plain-syntax">;</span>
</pre>
<ul class="endnotetexts"><li>This code is used in <a href="5-cbal.html#SP4_4_4_1">&#167;4.4.4.1</a>.</li></ul>
<p class="commentary firstcommentary"><a id="SP4_4_4_3" class="paragraph-anchor"></a><b>&#167;4.4.4.3. </b>There need not be a default switch case, but if there is, then:
</p>

<p class="commentary"><span class="named-paragraph-container code-font"><span class="named-paragraph-defn">Handle a pointery default</span><span class="named-paragraph-number">4.4.4.3</span></span><span class="comment-syntax"> =</span>
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="plain-syntax">    </span><span class="identifier-syntax">statement_count</span><span class="plain-syntax"> = </span><a href="5-cbal.html#SP2" class="function-link"><span class="function-syntax">CompileBlocksAndLines::code_block</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">statement_count</span><span class="plain-syntax">, </span><span class="identifier-syntax">ow_node</span><span class="plain-syntax">,</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">FALSE</span><span class="plain-syntax">, </span><span class="identifier-syntax">allow_implied_newlines</span><span class="plain-syntax">, </span><span class="identifier-syntax">last_loc</span><span class="plain-syntax">);</span>
</pre>
<ul class="endnotetexts"><li>This code is used in <a href="5-cbal.html#SP4_4_4">&#167;4.4.4</a>.</li></ul>
<p class="commentary firstcommentary"><a id="SP4_4_4_4" class="paragraph-anchor"></a><b>&#167;4.4.4.4. </b><span class="named-paragraph-container code-font"><span class="named-paragraph-defn">End a pointery switch</span><span class="named-paragraph-number">4.4.4.4</span></span><span class="comment-syntax"> =</span>
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="plain-syntax">    </span><span class="reserved-syntax">while</span><span class="plain-syntax"> (</span><span class="identifier-syntax">downs</span><span class="plain-syntax">-- &gt; </span><span class="constant-syntax">0</span><span class="plain-syntax">) </span><span class="identifier-syntax">EmitCode::up</span><span class="plain-syntax">();</span>
<span class="plain-syntax">    </span><a href="3-cb.html#SP13" class="function-link"><span class="function-syntax">CodeBlocks::close_code_block</span></a><span class="plain-syntax">();</span>
</pre>
<ul class="endnotetexts"><li>This code is used in <a href="5-cbal.html#SP4_4_4">&#167;4.4.4</a>.</li></ul>
<p class="commentary firstcommentary"><a id="SP4_4_4_5" class="paragraph-anchor"></a><b>&#167;4.4.4.5. </b>And now the more efficient case, using Inter's <span class="extract"><span class="extract-syntax">SWITCH_BIP</span></span>, <span class="extract"><span class="extract-syntax">CASE_BIP</span></span> and
<span class="extract"><span class="extract-syntax">DEFAULT_BIP</span></span> instructions.
</p>

<p class="commentary"><span class="named-paragraph-container code-font"><span class="named-paragraph-defn">Begin a non-pointery switch</span><span class="named-paragraph-number">4.4.4.5</span></span><span class="comment-syntax"> =</span>
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="plain-syntax">    </span><span class="identifier-syntax">EmitCode::inv</span><span class="plain-syntax">(</span><span class="identifier-syntax">SWITCH_BIP</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">EmitCode::down</span><span class="plain-syntax">();</span>
<span class="plain-syntax">        </span><a href="2-cv.html#SP5" class="function-link"><span class="function-syntax">CompileValues::to_code_val_of_kind</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">switch_val</span><span class="plain-syntax">, </span><span class="identifier-syntax">switch_kind</span><span class="plain-syntax">);</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">EmitCode::code</span><span class="plain-syntax">();</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">EmitCode::down</span><span class="plain-syntax">();</span>
</pre>
<ul class="endnotetexts"><li>This code is used in <a href="5-cbal.html#SP4_4_4">&#167;4.4.4</a>.</li></ul>
<p class="commentary firstcommentary"><a id="SP4_4_4_1_2" class="paragraph-anchor"></a><b>&#167;4.4.4.1.2. </b><span class="named-paragraph-container code-font"><span class="named-paragraph-defn">Handle a non-pointery case</span><span class="named-paragraph-number">4.4.4.1.2</span></span><span class="comment-syntax"> =</span>
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="plain-syntax">    </span><span class="identifier-syntax">EmitCode::inv</span><span class="plain-syntax">(</span><span class="identifier-syntax">CASE_BIP</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">EmitCode::down</span><span class="plain-syntax">();</span>
<span class="plain-syntax">        </span><a href="2-cv.html#SP5" class="function-link"><span class="function-syntax">CompileValues::to_code_val_of_kind</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">case_spec</span><span class="plain-syntax">, </span><span class="identifier-syntax">switch_kind</span><span class="plain-syntax">);</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">EmitCode::code</span><span class="plain-syntax">();</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">EmitCode::down</span><span class="plain-syntax">();</span>
<span class="plain-syntax">            </span><span class="identifier-syntax">statement_count</span><span class="plain-syntax"> = </span><a href="5-cbal.html#SP2" class="function-link"><span class="function-syntax">CompileBlocksAndLines::code_block</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">statement_count</span><span class="plain-syntax">,</span>
<span class="plain-syntax">                </span><span class="identifier-syntax">ow_node</span><span class="plain-syntax">, </span><span class="identifier-syntax">FALSE</span><span class="plain-syntax">, </span><span class="identifier-syntax">allow_implied_newlines</span><span class="plain-syntax">, </span><span class="identifier-syntax">last_loc</span><span class="plain-syntax">);</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">EmitCode::up</span><span class="plain-syntax">();</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">EmitCode::up</span><span class="plain-syntax">();</span>
</pre>
<ul class="endnotetexts"><li>This code is used in <a href="5-cbal.html#SP4_4_4_1">&#167;4.4.4.1</a>.</li></ul>
<p class="commentary firstcommentary"><a id="SP4_4_4_6" class="paragraph-anchor"></a><b>&#167;4.4.4.6. </b><span class="named-paragraph-container code-font"><span class="named-paragraph-defn">Handle a non-pointery default</span><span class="named-paragraph-number">4.4.4.6</span></span><span class="comment-syntax"> =</span>
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="plain-syntax">    </span><span class="identifier-syntax">EmitCode::inv</span><span class="plain-syntax">(</span><span class="identifier-syntax">DEFAULT_BIP</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">EmitCode::down</span><span class="plain-syntax">();</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">EmitCode::code</span><span class="plain-syntax">();</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">EmitCode::down</span><span class="plain-syntax">();</span>
<span class="plain-syntax">            </span><span class="identifier-syntax">statement_count</span><span class="plain-syntax"> = </span><a href="5-cbal.html#SP2" class="function-link"><span class="function-syntax">CompileBlocksAndLines::code_block</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">statement_count</span><span class="plain-syntax">,</span>
<span class="plain-syntax">                </span><span class="identifier-syntax">ow_node</span><span class="plain-syntax">, </span><span class="identifier-syntax">FALSE</span><span class="plain-syntax">, </span><span class="identifier-syntax">allow_implied_newlines</span><span class="plain-syntax">, </span><span class="identifier-syntax">last_loc</span><span class="plain-syntax">);</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">EmitCode::up</span><span class="plain-syntax">();</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">EmitCode::up</span><span class="plain-syntax">();</span>
</pre>
<ul class="endnotetexts"><li>This code is used in <a href="5-cbal.html#SP4_4_4">&#167;4.4.4</a>.</li></ul>
<p class="commentary firstcommentary"><a id="SP4_4_4_7" class="paragraph-anchor"></a><b>&#167;4.4.4.7. </b><span class="named-paragraph-container code-font"><span class="named-paragraph-defn">End a non-pointery switch</span><span class="named-paragraph-number">4.4.4.7</span></span><span class="comment-syntax"> =</span>
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="plain-syntax">    </span><span class="identifier-syntax">EmitCode::up</span><span class="plain-syntax">();</span>
<span class="plain-syntax">    </span><a href="3-cb.html#SP13" class="function-link"><span class="function-syntax">CodeBlocks::close_code_block</span></a><span class="plain-syntax">();</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">EmitCode::up</span><span class="plain-syntax">();</span>
</pre>
<ul class="endnotetexts"><li>This code is used in <a href="5-cbal.html#SP4_4_4">&#167;4.4.4</a>.</li></ul>
<p class="commentary firstcommentary"><a id="SP4_4_4_8" class="paragraph-anchor"></a><b>&#167;4.4.4.8. </b>In either implementation, we perform this check:
</p>

<p class="commentary"><span class="named-paragraph-container code-font"><span class="named-paragraph-defn">Test for duplicate cases</span><span class="named-paragraph-number">4.4.4.8</span></span><span class="comment-syntax"> =</span>
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="plain-syntax">    </span><span class="reserved-syntax">for</span><span class="plain-syntax"> (</span><span class="identifier-syntax">parse_node</span><span class="plain-syntax"> *</span><span class="identifier-syntax">A</span><span class="plain-syntax"> = </span><span class="identifier-syntax">p</span><span class="plain-syntax">-&gt;</span><span class="identifier-syntax">down</span><span class="plain-syntax">-&gt;</span><span class="identifier-syntax">next</span><span class="plain-syntax">-&gt;</span><span class="identifier-syntax">next</span><span class="plain-syntax">; </span><span class="identifier-syntax">A</span><span class="plain-syntax">; </span><span class="identifier-syntax">A</span><span class="plain-syntax"> = </span><span class="identifier-syntax">A</span><span class="plain-syntax">-&gt;</span><span class="identifier-syntax">next</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">int</span><span class="plain-syntax"> </span><span class="identifier-syntax">dup</span><span class="plain-syntax"> = </span><span class="identifier-syntax">FALSE</span><span class="plain-syntax">;</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">for</span><span class="plain-syntax"> (</span><span class="identifier-syntax">parse_node</span><span class="plain-syntax"> *</span><span class="identifier-syntax">B</span><span class="plain-syntax"> = </span><span class="identifier-syntax">A</span><span class="plain-syntax">-&gt;</span><span class="identifier-syntax">next</span><span class="plain-syntax">; </span><span class="identifier-syntax">B</span><span class="plain-syntax">; </span><span class="identifier-syntax">B</span><span class="plain-syntax"> = </span><span class="identifier-syntax">B</span><span class="plain-syntax">-&gt;</span><span class="identifier-syntax">next</span><span class="plain-syntax">)</span>
<span class="plain-syntax">            </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">Rvalues::compare_CONSTANT</span><span class="plain-syntax">(</span>
<span class="plain-syntax">                </span><span class="identifier-syntax">Node::get_evaluation</span><span class="plain-syntax">(</span><span class="identifier-syntax">A</span><span class="plain-syntax">), </span><span class="identifier-syntax">Node::get_evaluation</span><span class="plain-syntax">(</span><span class="identifier-syntax">B</span><span class="plain-syntax">)))</span>
<span class="plain-syntax">                    </span><span class="identifier-syntax">dup</span><span class="plain-syntax"> = </span><span class="identifier-syntax">TRUE</span><span class="plain-syntax">;</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">dup</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">            </span><span class="identifier-syntax">current_sentence</span><span class="plain-syntax"> = </span><span class="identifier-syntax">A</span><span class="plain-syntax">;</span>
<span class="plain-syntax">            </span><span class="identifier-syntax">Problems::quote_source</span><span class="plain-syntax">(1, </span><span class="identifier-syntax">A</span><span class="plain-syntax">);</span>
<span class="plain-syntax">            </span><span class="identifier-syntax">Problems::quote_spec</span><span class="plain-syntax">(2, </span><span class="identifier-syntax">Node::get_evaluation</span><span class="plain-syntax">(</span><span class="identifier-syntax">A</span><span class="plain-syntax">));</span>
<span class="plain-syntax">            </span><span class="identifier-syntax">StandardProblems::handmade_problem</span><span class="plain-syntax">(</span><span class="identifier-syntax">Task::syntax_tree</span><span class="plain-syntax">(),</span>
<span class="plain-syntax">                </span><span class="identifier-syntax">_p_</span><span class="plain-syntax">(</span><span class="identifier-syntax">PM_CaseValueDuplicated</span><span class="plain-syntax">));</span>
<span class="plain-syntax">            </span><span class="identifier-syntax">Problems::issue_problem_segment</span><span class="plain-syntax">(</span>
<span class="plain-syntax">                </span><span class="string-syntax">"The case %1 occurs more than once in this 'if' switch."</span><span class="plain-syntax">);</span>
<span class="plain-syntax">            </span><span class="identifier-syntax">Problems::issue_problem_end</span><span class="plain-syntax">();</span>
<span class="plain-syntax">        }</span>
<span class="plain-syntax">    }</span>
</pre>
<ul class="endnotetexts"><li>This code is used in <a href="5-cbal.html#SP4_4_4">&#167;4.4.4</a>.</li></ul>
<p class="commentary firstcommentary"><a id="SP4_4_5" class="paragraph-anchor"></a><b>&#167;4.4.5. </b><span class="named-paragraph-container code-font"><span class="named-paragraph-defn">Compile a standard midriff</span><span class="named-paragraph-number">4.4.5</span></span><span class="comment-syntax"> =</span>
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="plain-syntax">    </span><span class="identifier-syntax">current_sentence</span><span class="plain-syntax"> = </span><span class="identifier-syntax">to_compile</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><a href="5-cbal.html#SP6" class="function-link"><span class="function-syntax">CompileBlocksAndLines::evaluate_invocation</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">to_compile</span><span class="plain-syntax">, </span><span class="identifier-syntax">FALSE</span><span class="plain-syntax">, </span><span class="identifier-syntax">INTER_VOID_VHMODE</span><span class="plain-syntax">,</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">allow_implied_newlines</span><span class="plain-syntax">);</span>
</pre>
<ul class="endnotetexts"><li>This code is used in <a href="5-cbal.html#SP4_4">&#167;4.4</a>.</li></ul>
<p class="commentary firstcommentary"><a id="SP4_5" class="paragraph-anchor"></a><b>&#167;4.5. Tail code for lines.</b><span class="named-paragraph-container code-font"><span class="named-paragraph-defn">Compile the tail</span><span class="named-paragraph-number">4.5</span></span><span class="comment-syntax"> =</span>
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">csp</span><span class="plain-syntax"> == </span><span class="identifier-syntax">if_CSP</span><span class="plain-syntax">) </span><span class="named-paragraph-container code-font"><a href="5-cbal.html#SP4_5_1" class="named-paragraph-link"><span class="named-paragraph">Compile an if tail</span><span class="named-paragraph-number">4.5.1</span></a></span>
<span class="plain-syntax">    </span><span class="reserved-syntax">else</span><span class="plain-syntax"> </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">csp</span><span class="plain-syntax"> == </span><span class="identifier-syntax">switch_CSP</span><span class="plain-syntax">) </span><span class="named-paragraph-container code-font"><a href="5-cbal.html#SP4_5_2" class="named-paragraph-link"><span class="named-paragraph">Compile a switch tail</span><span class="named-paragraph-number">4.5.2</span></a></span>
<span class="plain-syntax">    </span><span class="reserved-syntax">else</span><span class="plain-syntax"> </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">csp</span><span class="plain-syntax"> == </span><span class="identifier-syntax">say_CSP</span><span class="plain-syntax">) </span><span class="named-paragraph-container code-font"><a href="5-cbal.html#SP4_5_3" class="named-paragraph-link"><span class="named-paragraph">Compile a say tail</span><span class="named-paragraph-number">4.5.3</span></a></span>
<span class="plain-syntax">    </span><span class="reserved-syntax">else</span><span class="plain-syntax"> </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">csp</span><span class="plain-syntax"> == </span><span class="identifier-syntax">instead_CSP</span><span class="plain-syntax">) </span><span class="named-paragraph-container code-font"><a href="5-cbal.html#SP4_5_4" class="named-paragraph-link"><span class="named-paragraph">Compile an instead tail</span><span class="named-paragraph-number">4.5.4</span></a></span>
<span class="plain-syntax">    </span><span class="reserved-syntax">else</span><span class="plain-syntax"> </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">ControlStructures::opens_block</span><span class="plain-syntax">(</span><span class="identifier-syntax">csp</span><span class="plain-syntax">)) </span><span class="named-paragraph-container code-font"><a href="5-cbal.html#SP4_5_5" class="named-paragraph-link"><span class="named-paragraph">Compile a loop tail</span><span class="named-paragraph-number">4.5.5</span></a></span><span class="plain-syntax">;</span>
</pre>
<ul class="endnotetexts"><li>This code is used in <a href="5-cbal.html#SP4">&#167;4</a>.</li></ul>
<p class="commentary firstcommentary"><a id="SP4_5_1" class="paragraph-anchor"></a><b>&#167;4.5.1. </b><span class="named-paragraph-container code-font"><span class="named-paragraph-defn">Compile an if tail</span><span class="named-paragraph-number">4.5.1</span></span><span class="comment-syntax"> =</span>
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="plain-syntax">    ;</span>
</pre>
<ul class="endnotetexts"><li>This code is used in <a href="5-cbal.html#SP4_5">&#167;4.5</a>.</li></ul>
<p class="commentary firstcommentary"><a id="SP4_5_2" class="paragraph-anchor"></a><b>&#167;4.5.2. </b><span class="named-paragraph-container code-font"><span class="named-paragraph-defn">Compile a switch tail</span><span class="named-paragraph-number">4.5.2</span></span><span class="comment-syntax"> =</span>
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="plain-syntax">    ;</span>
</pre>
<ul class="endnotetexts"><li>This code is used in <a href="5-cbal.html#SP4_5">&#167;4.5</a>.</li></ul>
<p class="commentary firstcommentary"><a id="SP4_4_4_9" class="paragraph-anchor"></a><b>&#167;4.4.4.9. </b><span class="named-paragraph-container code-font"><span class="named-paragraph-defn">Issue problem message for unknown case value</span><span class="named-paragraph-number">4.4.4.9</span></span><span class="comment-syntax"> =</span>
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="plain-syntax">    </span><span class="identifier-syntax">StandardProblems::sentence_problem</span><span class="plain-syntax">(</span><span class="identifier-syntax">Task::syntax_tree</span><span class="plain-syntax">(), </span><span class="identifier-syntax">_p_</span><span class="plain-syntax">(</span><span class="identifier-syntax">PM_CaseValueUnknown</span><span class="plain-syntax">),</span>
<span class="plain-syntax">        </span><span class="string-syntax">"I don't recognise this case value"</span><span class="plain-syntax">,</span>
<span class="plain-syntax">        </span><span class="string-syntax">"that is, the value written after the '--'."</span><span class="plain-syntax">);</span>
</pre>
<ul class="endnotetexts"><li>This code is used in <a href="5-cbal.html#SP4_4_4">&#167;4.4.4</a> (twice).</li></ul>
<p class="commentary firstcommentary"><a id="SP4_5_3" class="paragraph-anchor"></a><b>&#167;4.5.3. </b>As will be seen, two sets of labels and counters are kept here: see the
inline definitions for "say if" and similar.
</p>

<p class="commentary"><span class="named-paragraph-container code-font"><span class="named-paragraph-defn">Compile a say tail</span><span class="named-paragraph-number">4.5.3</span></span><span class="comment-syntax"> =</span>
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="plain-syntax">    </span><span class="identifier-syntax">statement_count</span><span class="plain-syntax"> = </span><a href="5-cbal.html#SP2" class="function-link"><span class="function-syntax">CompileBlocksAndLines::code_block</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">statement_count</span><span class="plain-syntax">, </span><span class="identifier-syntax">p</span><span class="plain-syntax">,</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">FALSE</span><span class="plain-syntax">, </span><span class="identifier-syntax">allow_implied_newlines</span><span class="plain-syntax">, </span><span class="identifier-syntax">last_loc</span><span class="plain-syntax">);</span>

<span class="plain-syntax">    </span><span class="identifier-syntax">TEMPORARY_TEXT</span><span class="plain-syntax">(</span><span class="identifier-syntax">SAYL</span><span class="plain-syntax">)</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">WRITE_TO</span><span class="plain-syntax">(</span><span class="identifier-syntax">SAYL</span><span class="plain-syntax">, </span><span class="string-syntax">"."</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><a href="3-jl.html#SP2" class="function-link"><span class="function-syntax">JumpLabels::write</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">SAYL</span><span class="plain-syntax">, </span><span class="identifier-syntax">I</span><span class="string-syntax">"Say"</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">EmitCode::place_label</span><span class="plain-syntax">(</span><span class="identifier-syntax">EmitCode::reserve_label</span><span class="plain-syntax">(</span><span class="identifier-syntax">SAYL</span><span class="plain-syntax">));</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">DISCARD_TEXT</span><span class="plain-syntax">(</span><span class="identifier-syntax">SAYL</span><span class="plain-syntax">)</span>

<span class="plain-syntax">    </span><a href="3-jl.html#SP5" class="function-link"><span class="function-syntax">JumpLabels::read_counter</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">I</span><span class="string-syntax">"Say"</span><span class="plain-syntax">, </span><span class="constant-syntax">1</span><span class="plain-syntax">);</span>

<span class="plain-syntax">    </span><span class="identifier-syntax">TEMPORARY_TEXT</span><span class="plain-syntax">(</span><span class="identifier-syntax">SAYXL</span><span class="plain-syntax">)</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">WRITE_TO</span><span class="plain-syntax">(</span><span class="identifier-syntax">SAYXL</span><span class="plain-syntax">, </span><span class="string-syntax">"."</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><a href="3-jl.html#SP2" class="function-link"><span class="function-syntax">JumpLabels::write</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">SAYXL</span><span class="plain-syntax">, </span><span class="identifier-syntax">I</span><span class="string-syntax">"SayX"</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">EmitCode::place_label</span><span class="plain-syntax">(</span><span class="identifier-syntax">EmitCode::reserve_label</span><span class="plain-syntax">(</span><span class="identifier-syntax">SAYXL</span><span class="plain-syntax">));</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">DISCARD_TEXT</span><span class="plain-syntax">(</span><span class="identifier-syntax">SAYXL</span><span class="plain-syntax">)</span>

<span class="plain-syntax">    </span><a href="3-jl.html#SP5" class="function-link"><span class="function-syntax">JumpLabels::read_counter</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">I</span><span class="string-syntax">"SayX"</span><span class="plain-syntax">, </span><span class="constant-syntax">1</span><span class="plain-syntax">);</span>
</pre>
<ul class="endnotetexts"><li>This code is used in <a href="5-cbal.html#SP4_5">&#167;4.5</a>.</li></ul>
<p class="commentary firstcommentary"><a id="SP4_5_4" class="paragraph-anchor"></a><b>&#167;4.5.4. </b><span class="named-paragraph-container code-font"><span class="named-paragraph-defn">Compile an instead tail</span><span class="named-paragraph-number">4.5.4</span></span><span class="comment-syntax"> =</span>
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="plain-syntax">    </span><span class="identifier-syntax">EmitCode::rtrue</span><span class="plain-syntax">();</span>
</pre>
<ul class="endnotetexts"><li>This code is used in <a href="5-cbal.html#SP4_5">&#167;4.5</a>.</li></ul>
<p class="commentary firstcommentary"><a id="SP4_5_5" class="paragraph-anchor"></a><b>&#167;4.5.5. </b><span class="named-paragraph-container code-font"><span class="named-paragraph-defn">Compile a loop tail</span><span class="named-paragraph-number">4.5.5</span></span><span class="comment-syntax"> =</span>
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="plain-syntax">    </span><a href="3-cb.html#SP11" class="function-link"><span class="function-syntax">CodeBlocks::open_code_block</span></a><span class="plain-syntax">();</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">statement_count</span><span class="plain-syntax"> = </span><a href="5-cbal.html#SP2" class="function-link"><span class="function-syntax">CompileBlocksAndLines::code_block</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">statement_count</span><span class="plain-syntax">, </span><span class="identifier-syntax">p</span><span class="plain-syntax">-&gt;</span><span class="identifier-syntax">down</span><span class="plain-syntax">-&gt;</span><span class="identifier-syntax">next</span><span class="plain-syntax">,</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">FALSE</span><span class="plain-syntax">, </span><span class="identifier-syntax">allow_implied_newlines</span><span class="plain-syntax">, </span><span class="identifier-syntax">last_loc</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">while</span><span class="plain-syntax"> (</span><span class="identifier-syntax">EmitCode::level</span><span class="plain-syntax">() &gt; </span><span class="identifier-syntax">L</span><span class="plain-syntax">) </span><span class="identifier-syntax">EmitCode::up</span><span class="plain-syntax">();</span>
<span class="plain-syntax">    </span><a href="3-cb.html#SP13" class="function-link"><span class="function-syntax">CodeBlocks::close_code_block</span></a><span class="plain-syntax">();</span>
</pre>
<ul class="endnotetexts"><li>This code is used in <a href="5-cbal.html#SP4_5">&#167;4.5</a>.</li></ul>
<p class="commentary firstcommentary"><a id="SP5" class="paragraph-anchor"></a><b>&#167;5. Nows.</b></p>

<pre class="displayed-code all-displayed-code code-font">
<span class="reserved-syntax">void</span><span class="plain-syntax"> </span><span class="function-syntax">CompileBlocksAndLines::compile_a_now</span><button class="popup" onclick="togglePopup('usagePopup4')"><span class="comment-syntax">?</span><span class="popuptext" id="usagePopup4">Usage of <span class="code-font"><span class="function-syntax">CompileBlocksAndLines::compile_a_now</span></span>:<br/>Compile Invocations Inline - <a href="5-cii.html#SP6_1_1_4_6">&#167;6.1.1.4.6</a></span></button><span class="plain-syntax">(</span><span class="identifier-syntax">wording</span><span class="plain-syntax"> </span><span class="identifier-syntax">XW</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">parse_node</span><span class="plain-syntax"> *</span><span class="identifier-syntax">cs</span><span class="plain-syntax"> = </span><span class="identifier-syntax">NULL</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="function-syntax">&lt;s-condition&gt;</span><span class="plain-syntax">(</span><span class="identifier-syntax">XW</span><span class="plain-syntax">)) </span><span class="identifier-syntax">cs</span><span class="plain-syntax"> = </span><span class="function-syntax">&lt;&lt;rp&gt;&gt;</span><span class="plain-syntax">; </span><span class="reserved-syntax">else</span><span class="plain-syntax"> </span><span class="identifier-syntax">cs</span><span class="plain-syntax"> = </span><span class="identifier-syntax">Specifications::new_UNKNOWN</span><span class="plain-syntax">(</span><span class="identifier-syntax">XW</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">LOGIF</span><span class="plain-syntax">(</span><span class="identifier-syntax">MATCHING</span><span class="plain-syntax">, </span><span class="string-syntax">"Now cond is $T\n"</span><span class="plain-syntax">, </span><span class="identifier-syntax">cs</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">int</span><span class="plain-syntax"> </span><span class="identifier-syntax">rv</span><span class="plain-syntax"> = </span><span class="identifier-syntax">Dash::check_condition</span><span class="plain-syntax">(</span><span class="identifier-syntax">cs</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">LOGIF</span><span class="plain-syntax">(</span><span class="identifier-syntax">MATCHING</span><span class="plain-syntax">, </span><span class="string-syntax">"After Dash, it's $T\n"</span><span class="plain-syntax">, </span><span class="identifier-syntax">cs</span><span class="plain-syntax">);</span>

<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">Node::is</span><span class="plain-syntax">(</span><span class="identifier-syntax">cs</span><span class="plain-syntax">, </span><span class="identifier-syntax">TEST_PROPOSITION_NT</span><span class="plain-syntax">)) {</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">rv</span><span class="plain-syntax"> != </span><span class="identifier-syntax">NEVER_MATCH</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">            </span><span class="identifier-syntax">pcalc_prop</span><span class="plain-syntax"> *</span><span class="identifier-syntax">prop</span><span class="plain-syntax"> = </span><span class="identifier-syntax">Specifications::to_proposition</span><span class="plain-syntax">(</span><span class="identifier-syntax">cs</span><span class="plain-syntax">);</span>
<span class="plain-syntax">            </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">prop</span><span class="plain-syntax">) </span><a href="4-cp.html#SP4" class="function-link"><span class="function-syntax">CompilePropositions::to_make_true</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">prop</span><span class="plain-syntax">);</span>
<span class="plain-syntax">        }</span>
<span class="plain-syntax">    } </span><span class="reserved-syntax">else</span><span class="plain-syntax"> </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">Specifications::is_condition</span><span class="plain-syntax">(</span><span class="identifier-syntax">cs</span><span class="plain-syntax">))</span>
<span class="plain-syntax">        </span><span class="named-paragraph-container code-font"><a href="5-cbal.html#SP5_1" class="named-paragraph-link"><span class="named-paragraph">Issue a problem message for the wrong sort of condition in a "now"</span><span class="named-paragraph-number">5.1</span></a></span>
<span class="plain-syntax">    </span><span class="reserved-syntax">else</span><span class="plain-syntax"> </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">rv</span><span class="plain-syntax"> != </span><span class="identifier-syntax">NEVER_MATCH</span><span class="plain-syntax">) </span><span class="named-paragraph-container code-font"><a href="5-cbal.html#SP5_2" class="named-paragraph-link"><span class="named-paragraph">Issue a problem message for an unrecognised condition</span><span class="named-paragraph-number">5.2</span></a></span><span class="plain-syntax">;</span>
<span class="plain-syntax">}</span>
</pre>
<p class="commentary firstcommentary"><a id="SP5_1" class="paragraph-anchor"></a><b>&#167;5.1. </b><span class="named-paragraph-container code-font"><span class="named-paragraph-defn">Issue a problem message for the wrong sort of condition in a "now"</span><span class="named-paragraph-number">5.1</span></span><span class="comment-syntax"> =</span>
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="plain-syntax">    </span><span class="identifier-syntax">Problems::quote_source</span><span class="plain-syntax">(1, </span><span class="identifier-syntax">current_sentence</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">Problems::quote_wording</span><span class="plain-syntax">(2, </span><span class="identifier-syntax">Node::get_text</span><span class="plain-syntax">(</span><span class="identifier-syntax">cs</span><span class="plain-syntax">));</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">Node::is</span><span class="plain-syntax">(</span><span class="identifier-syntax">cs</span><span class="plain-syntax">, </span><span class="identifier-syntax">TEST_VALUE_NT</span><span class="plain-syntax">)) {</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">StandardProblems::handmade_problem</span><span class="plain-syntax">(</span><span class="identifier-syntax">Task::syntax_tree</span><span class="plain-syntax">(), </span><span class="identifier-syntax">_p_</span><span class="plain-syntax">(</span><span class="identifier-syntax">PM_BadNow1</span><span class="plain-syntax">));</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">Problems::issue_problem_segment</span><span class="plain-syntax">(</span>
<span class="plain-syntax">            </span><span class="string-syntax">"You wrote %1, but although '%2' is a condition which it is legal to test "</span>
<span class="plain-syntax">            </span><span class="string-syntax">"with 'if', 'when', and so forth, it is not something I can arrange to happen "</span>
<span class="plain-syntax">            </span><span class="string-syntax">"on request. Whether it is true or not depends on current circumstances: so "</span>
<span class="plain-syntax">            </span><span class="string-syntax">"to make it true, you will need to adjust those circumstances."</span><span class="plain-syntax">);</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">Problems::issue_problem_end</span><span class="plain-syntax">();</span>
<span class="plain-syntax">    } </span><span class="reserved-syntax">else</span><span class="plain-syntax"> </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">Node::is</span><span class="plain-syntax">(</span><span class="identifier-syntax">cs</span><span class="plain-syntax">, </span><span class="identifier-syntax">LOGICAL_AND_NT</span><span class="plain-syntax">)) {</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">StandardProblems::handmade_problem</span><span class="plain-syntax">(</span><span class="identifier-syntax">Task::syntax_tree</span><span class="plain-syntax">(), </span><span class="identifier-syntax">_p_</span><span class="plain-syntax">(</span><span class="identifier-syntax">PM_BadNow2</span><span class="plain-syntax">));</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">Problems::issue_problem_segment</span><span class="plain-syntax">(</span>
<span class="plain-syntax">            </span><span class="string-syntax">"You wrote %1, but 'now' does not work with the condition '%2' because it can "</span>
<span class="plain-syntax">            </span><span class="string-syntax">"only make one wish come true at a time: so it doesn't like the 'and'. Try "</span>
<span class="plain-syntax">            </span><span class="string-syntax">"rewriting as two 'now's in a row?"</span><span class="plain-syntax">);</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">Problems::issue_problem_end</span><span class="plain-syntax">();</span>
<span class="plain-syntax">    } </span><span class="reserved-syntax">else</span><span class="plain-syntax"> {</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">StandardProblems::handmade_problem</span><span class="plain-syntax">(</span><span class="identifier-syntax">Task::syntax_tree</span><span class="plain-syntax">(), </span><span class="identifier-syntax">_p_</span><span class="plain-syntax">(</span><span class="identifier-syntax">PM_BadNow3</span><span class="plain-syntax">));</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">Problems::issue_problem_segment</span><span class="plain-syntax">(</span>
<span class="plain-syntax">            </span><span class="string-syntax">"You wrote %1, but '%2' isn't the sort of condition which can be made to be "</span>
<span class="plain-syntax">            </span><span class="string-syntax">"true, in the way that 'the ball is on the table' can be made true with a "</span>
<span class="plain-syntax">            </span><span class="string-syntax">"straightforward movement of one object (the ball)."</span><span class="plain-syntax">);</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">Problems::issue_problem_end</span><span class="plain-syntax">();</span>
<span class="plain-syntax">    }</span>
</pre>
<ul class="endnotetexts"><li>This code is used in <a href="5-cbal.html#SP5">&#167;5</a>.</li></ul>
<p class="commentary firstcommentary"><a id="SP5_2" class="paragraph-anchor"></a><b>&#167;5.2. </b><span class="named-paragraph-container code-font"><span class="named-paragraph-defn">Issue a problem message for an unrecognised condition</span><span class="named-paragraph-number">5.2</span></span><span class="comment-syntax"> =</span>
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="plain-syntax">    </span><span class="identifier-syntax">LOG</span><span class="plain-syntax">(</span><span class="string-syntax">"$T\n"</span><span class="plain-syntax">, </span><span class="identifier-syntax">current_sentence</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">Problems::quote_source</span><span class="plain-syntax">(1, </span><span class="identifier-syntax">current_sentence</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">Problems::quote_wording</span><span class="plain-syntax">(2, </span><span class="identifier-syntax">Node::get_text</span><span class="plain-syntax">(</span><span class="identifier-syntax">cs</span><span class="plain-syntax">));</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">StandardProblems::handmade_problem</span><span class="plain-syntax">(</span><span class="identifier-syntax">Task::syntax_tree</span><span class="plain-syntax">(), </span><span class="identifier-syntax">_p_</span><span class="plain-syntax">(</span><span class="identifier-syntax">BelievedImpossible</span><span class="plain-syntax">));</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">Problems::issue_problem_segment</span><span class="plain-syntax">(</span>
<span class="plain-syntax">        </span><span class="string-syntax">"You wrote %1, but '%2' isn't a condition, so I can't see how to make it true "</span>
<span class="plain-syntax">        </span><span class="string-syntax">"from here on."</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">Problems::issue_problem_end</span><span class="plain-syntax">();</span>
</pre>
<ul class="endnotetexts"><li>This code is used in <a href="5-cbal.html#SP5">&#167;5</a>.</li></ul>
<p class="commentary firstcommentary"><a id="SP6" class="paragraph-anchor"></a><b>&#167;6. The evaluator.</b>This function takes the text of a line from a phrase definition, parses it,
type-checks it, and finally, all being well, compiles it.
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="reserved-syntax">void</span><span class="plain-syntax"> </span><span class="function-syntax">CompileBlocksAndLines::evaluate_invocation</span><button class="popup" onclick="togglePopup('usagePopup5')"><span class="comment-syntax">?</span><span class="popuptext" id="usagePopup5">Usage of <span class="code-font"><span class="function-syntax">CompileBlocksAndLines::evaluate_invocation</span></span>:<br/><a href="5-cbal.html#SP4_4_1">&#167;4.4.1</a>, <a href="5-cbal.html#SP4_4_3">&#167;4.4.3</a>, <a href="5-cbal.html#SP4_4_4">&#167;4.4.4</a>, <a href="5-cbal.html#SP4_4_5">&#167;4.4.5</a></span></button><span class="plain-syntax">(</span><span class="identifier-syntax">parse_node</span><span class="plain-syntax"> *</span><span class="identifier-syntax">p</span><span class="plain-syntax">, </span><span class="reserved-syntax">int</span><span class="plain-syntax"> </span><span class="identifier-syntax">already_parsed</span><span class="plain-syntax">,</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">int</span><span class="plain-syntax"> </span><span class="identifier-syntax">vhm</span><span class="plain-syntax">, </span><span class="reserved-syntax">int</span><span class="plain-syntax"> </span><span class="identifier-syntax">allow_implied_newlines</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">int</span><span class="plain-syntax"> </span><span class="identifier-syntax">initial_problem_count</span><span class="plain-syntax"> = </span><span class="identifier-syntax">problem_count</span><span class="plain-syntax">;</span>

<span class="plain-syntax">    </span><span class="identifier-syntax">LOGIF</span><span class="plain-syntax">(</span><span class="identifier-syntax">EXPRESSIONS</span><span class="plain-syntax">, </span><span class="string-syntax">"\n-- -- Evaluating &lt;%W&gt; -- --\n"</span><span class="plain-syntax">, </span><span class="identifier-syntax">Node::get_text</span><span class="plain-syntax">(</span><span class="identifier-syntax">p</span><span class="plain-syntax">));</span>

<span class="plain-syntax">    </span><span class="identifier-syntax">LOGIF</span><span class="plain-syntax">(</span><span class="identifier-syntax">EXPRESSIONS</span><span class="plain-syntax">, </span><span class="string-syntax">"(a) Parsing:\n"</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">already_parsed</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">parse_node</span><span class="plain-syntax"> *</span><span class="identifier-syntax">inv</span><span class="plain-syntax"> = </span><span class="identifier-syntax">InvocationLists::first_reading</span><span class="plain-syntax">(</span><span class="identifier-syntax">p</span><span class="plain-syntax">-&gt;</span><span class="identifier-syntax">down</span><span class="plain-syntax">);</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">if</span><span class="plain-syntax"> ((</span><span class="identifier-syntax">inv</span><span class="plain-syntax">) &amp;&amp;</span>
<span class="plain-syntax">            (</span><span class="identifier-syntax">Node::get_phrase_invoked</span><span class="plain-syntax">(</span><span class="identifier-syntax">inv</span><span class="plain-syntax">)) &amp;&amp;</span>
<span class="plain-syntax">            (</span><span class="identifier-syntax">IDTypeData::is_a_say_phrase</span><span class="plain-syntax">(</span><span class="identifier-syntax">Node::get_phrase_invoked</span><span class="plain-syntax">(</span><span class="identifier-syntax">inv</span><span class="plain-syntax">))) &amp;&amp;</span>
<span class="plain-syntax">            (</span><span class="identifier-syntax">Node::get_phrase_invoked</span><span class="plain-syntax">(</span><span class="identifier-syntax">inv</span><span class="plain-syntax">)-&gt;</span><span class="identifier-syntax">type_data</span><span class="plain-syntax">.</span><span class="identifier-syntax">as_say</span><span class="plain-syntax">.</span><span class="identifier-syntax">say_control_structure</span><span class="plain-syntax"> == </span><span class="identifier-syntax">NO_SAY_CS</span><span class="plain-syntax">)) {</span>
<span class="plain-syntax">            </span><span class="identifier-syntax">EmitCode::call</span><span class="plain-syntax">(</span><span class="identifier-syntax">Hierarchy::find</span><span class="plain-syntax">(</span><span class="identifier-syntax">PARACONTENT_HL</span><span class="plain-syntax">));</span>
<span class="plain-syntax">        }</span>
<span class="plain-syntax">    } </span><span class="reserved-syntax">else</span><span class="plain-syntax"> {</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">SParser::parse_void_phrase</span><span class="plain-syntax">(</span><span class="identifier-syntax">p</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    }</span>

<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">initial_problem_count</span><span class="plain-syntax"> == </span><span class="identifier-syntax">problem_count</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">LOGIF</span><span class="plain-syntax">(</span><span class="identifier-syntax">EXPRESSIONS</span><span class="plain-syntax">, </span><span class="string-syntax">"(b) Type checking:\n$E"</span><span class="plain-syntax">, </span><span class="identifier-syntax">p</span><span class="plain-syntax">-&gt;</span><span class="identifier-syntax">down</span><span class="plain-syntax">);</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">Dash::check_invl</span><span class="plain-syntax">(</span><span class="identifier-syntax">p</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    }</span>

<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">initial_problem_count</span><span class="plain-syntax"> == </span><span class="identifier-syntax">problem_count</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">LOGIF</span><span class="plain-syntax">(</span><span class="identifier-syntax">EXPRESSIONS</span><span class="plain-syntax">, </span><span class="string-syntax">"(c) Compilation:\n$E"</span><span class="plain-syntax">, </span><span class="identifier-syntax">p</span><span class="plain-syntax">-&gt;</span><span class="identifier-syntax">down</span><span class="plain-syntax">);</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">value_holster</span><span class="plain-syntax"> </span><span class="identifier-syntax">VH</span><span class="plain-syntax"> = </span><span class="identifier-syntax">Holsters::new</span><span class="plain-syntax">(</span><span class="identifier-syntax">vhm</span><span class="plain-syntax">);</span>
<span class="plain-syntax">        </span><a href="5-ci.html#SP1" class="function-link"><span class="function-syntax">CompileInvocations::list</span></a><span class="plain-syntax">(&amp;</span><span class="identifier-syntax">VH</span><span class="plain-syntax">, </span><span class="identifier-syntax">p</span><span class="plain-syntax">-&gt;</span><span class="identifier-syntax">down</span><span class="plain-syntax">, </span><span class="identifier-syntax">Node::get_text</span><span class="plain-syntax">(</span><span class="identifier-syntax">p</span><span class="plain-syntax">), </span><span class="identifier-syntax">allow_implied_newlines</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    }</span>

<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">initial_problem_count</span><span class="plain-syntax"> == </span><span class="identifier-syntax">problem_count</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">LOGIF</span><span class="plain-syntax">(</span><span class="identifier-syntax">EXPRESSIONS</span><span class="plain-syntax">, </span><span class="string-syntax">"-- -- Completed -- --\n"</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    } </span><span class="reserved-syntax">else</span><span class="plain-syntax"> {</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">LOGIF</span><span class="plain-syntax">(</span><span class="identifier-syntax">EXPRESSIONS</span><span class="plain-syntax">, </span><span class="string-syntax">"-- -- Failed -- --\n"</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    }</span>
<span class="plain-syntax">}</span>
</pre>
<p class="commentary firstcommentary"><a id="SP7" class="paragraph-anchor"></a><b>&#167;7. Validating sequences of say invocations.</b>Test substitutions result in "say" invocations with multiple things to do:
here are examples, increasing in difficulty &mdash;
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="string-syntax">"Estates are worth at least [N]."</span>
<span class="string-syntax">"Platinum is shinier than [if a Colony is in the Supply Pile]gold[otherwise]silver."</span>
<span class="string-syntax">"The best defence is [one of]Lighthouse[or]Moat[or]having no money[at random]."</span>
</pre>
<p class="commentary">These imply 3, 5 and 9 individual invocations, respectively. The second and
third examples involve "say control structures", which means that those
invocations have to connect properly with each other: thus "[if...]" can be
followed by "[otherwise]", but "[otherwise]" must not occur on its own, and
so on. The final example is a so-called "segmented say phrase", or SSP.
</p>

<p class="commentary">These say control structures can even be nested, within limits:
</p>

<pre class="definitions code-font"><span class="definition-keyword">define</span> <span class="constant-syntax">MAX_COMPLEX_SAY_DEPTH</span><span class="plain-syntax"> </span><span class="constant-syntax">32</span><span class="plain-syntax"> </span><span class="comment-syntax"> and it would be terrible coding style to approach this</span>
</pre>
<p class="commentary firstcommentary"><a id="SP8" class="paragraph-anchor"></a><b>&#167;8. </b>The following function throws problem messages for each of the many ways these
say control structures can be abused. On correct code, it also annotates nodes
for SSP clauses in a way which will later help <a href="5-cii.html" class="internal">Compile Invocations Inline</a>.
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="reserved-syntax">void</span><span class="plain-syntax"> </span><span class="function-syntax">CompileBlocksAndLines::verify_say_node_list</span><button class="popup" onclick="togglePopup('usagePopup6')"><span class="comment-syntax">?</span><span class="popuptext" id="usagePopup6">Usage of <span class="code-font"><span class="function-syntax">CompileBlocksAndLines::verify_say_node_list</span></span>:<br/><a href="5-cbal.html#SP4_3_1">&#167;4.3.1</a></span></button><span class="plain-syntax">(</span><span class="identifier-syntax">parse_node</span><span class="plain-syntax"> *</span><span class="identifier-syntax">say_node_list</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">int</span><span class="plain-syntax"> </span><span class="identifier-syntax">problem_issued</span><span class="plain-syntax"> = </span><span class="identifier-syntax">FALSE</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">int</span><span class="plain-syntax"> </span><span class="identifier-syntax">it_was_not_worth_adding</span><span class="plain-syntax"> = </span><span class="identifier-syntax">TextSubstitutions::is_it_worth_adding</span><span class="plain-syntax">();</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">TextSubstitutions::it_is_not_worth_adding</span><span class="plain-syntax">();</span>

<span class="plain-syntax">    </span><span class="reserved-syntax">int</span><span class="plain-syntax"> </span><span class="identifier-syntax">SSP_sp</span><span class="plain-syntax"> = </span><span class="constant-syntax">0</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">int</span><span class="plain-syntax"> </span><span class="identifier-syntax">SSP_stack</span><span class="plain-syntax">[</span><span class="constant-syntax">MAX_COMPLEX_SAY_DEPTH</span><span class="plain-syntax">];</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">int</span><span class="plain-syntax"> </span><span class="identifier-syntax">SSP_stack_otherwised</span><span class="plain-syntax">[</span><span class="constant-syntax">MAX_COMPLEX_SAY_DEPTH</span><span class="plain-syntax">];</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">parse_node</span><span class="plain-syntax"> *</span><span class="identifier-syntax">SSP_invocations</span><span class="plain-syntax">[</span><span class="constant-syntax">MAX_COMPLEX_SAY_DEPTH</span><span class="plain-syntax">];</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">int</span><span class="plain-syntax"> </span><span class="identifier-syntax">say_if_nesting</span><span class="plain-syntax"> = </span><span class="constant-syntax">0</span><span class="plain-syntax">;</span>

<span class="plain-syntax">    </span><span class="reserved-syntax">for</span><span class="plain-syntax"> (</span><span class="identifier-syntax">parse_node</span><span class="plain-syntax"> *</span><span class="identifier-syntax">say_node</span><span class="plain-syntax"> = </span><span class="identifier-syntax">say_node_list</span><span class="plain-syntax">; </span><span class="identifier-syntax">say_node</span><span class="plain-syntax">; </span><span class="identifier-syntax">say_node</span><span class="plain-syntax"> = </span><span class="identifier-syntax">say_node</span><span class="plain-syntax">-&gt;</span><span class="identifier-syntax">next</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">parse_node</span><span class="plain-syntax"> *</span><span class="identifier-syntax">invl</span><span class="plain-syntax"> = </span><span class="identifier-syntax">say_node</span><span class="plain-syntax">-&gt;</span><span class="identifier-syntax">down</span><span class="plain-syntax">;</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">invl</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">            </span><span class="identifier-syntax">parse_node</span><span class="plain-syntax"> *</span><span class="identifier-syntax">inv</span><span class="plain-syntax">;</span>
<span class="plain-syntax">            </span><span class="identifier-syntax">LOOP_THROUGH_INVOCATION_LIST</span><span class="plain-syntax">(</span><span class="identifier-syntax">inv</span><span class="plain-syntax">, </span><span class="identifier-syntax">invl</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">                </span><span class="identifier-syntax">id_body</span><span class="plain-syntax"> *</span><span class="identifier-syntax">idb</span><span class="plain-syntax"> = </span><span class="identifier-syntax">Node::get_phrase_invoked</span><span class="plain-syntax">(</span><span class="identifier-syntax">inv</span><span class="plain-syntax">);</span>
<span class="plain-syntax">                </span><span class="reserved-syntax">if</span><span class="plain-syntax"> ((</span><span class="identifier-syntax">Node::get_phrase_invoked</span><span class="plain-syntax">(</span><span class="identifier-syntax">inv</span><span class="plain-syntax">)) &amp;&amp;</span>
<span class="plain-syntax">                    (</span><span class="identifier-syntax">IDTypeData::is_a_say_phrase</span><span class="plain-syntax">(</span><span class="identifier-syntax">idb</span><span class="plain-syntax">)))</span>
<span class="plain-syntax">                    </span><span class="named-paragraph-container code-font"><a href="5-cbal.html#SP8_1" class="named-paragraph-link"><span class="named-paragraph">This is a say invocation</span><span class="named-paragraph-number">8.1</span></a></span><span class="plain-syntax">;</span>
<span class="plain-syntax">            }</span>
<span class="plain-syntax">        }</span>
<span class="plain-syntax">    }</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">SSP_sp</span><span class="plain-syntax"> &gt; </span><span class="constant-syntax">0</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">if</span><span class="plain-syntax"> ((</span><span class="identifier-syntax">SSP_sp</span><span class="plain-syntax"> == </span><span class="constant-syntax">1</span><span class="plain-syntax">) &amp;&amp; (</span><span class="identifier-syntax">SSP_stack</span><span class="plain-syntax">[0] == -1)) {</span>
<span class="plain-syntax">            </span><span class="comment-syntax"> an if without an end if, which uniquely is legal</span>
<span class="plain-syntax">        } </span><span class="reserved-syntax">else</span><span class="plain-syntax"> {</span>
<span class="plain-syntax">            </span><span class="named-paragraph-container code-font"><a href="5-cbal.html#SP8_2" class="named-paragraph-link"><span class="named-paragraph">Issue a problem message for an SSP without end</span><span class="named-paragraph-number">8.2</span></a></span><span class="plain-syntax">;</span>
<span class="plain-syntax">        }</span>
<span class="plain-syntax">    }</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">it_was_not_worth_adding</span><span class="plain-syntax">) </span><span class="identifier-syntax">TextSubstitutions::it_is_not_worth_adding</span><span class="plain-syntax">();</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">else</span><span class="plain-syntax"> </span><span class="identifier-syntax">TextSubstitutions::it_is_worth_adding</span><span class="plain-syntax">();</span>
<span class="plain-syntax">}</span>
</pre>
<p class="commentary firstcommentary"><a id="SP8_1" class="paragraph-anchor"></a><b>&#167;8.1. </b><span class="named-paragraph-container code-font"><span class="named-paragraph-defn">This is a say invocation</span><span class="named-paragraph-number">8.1</span></span><span class="comment-syntax"> =</span>
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="plain-syntax">    </span><span class="reserved-syntax">int</span><span class="plain-syntax"> </span><span class="identifier-syntax">say_cs</span><span class="plain-syntax">, </span><span class="identifier-syntax">ssp_tok</span><span class="plain-syntax">, </span><span class="identifier-syntax">ssp_ctok</span><span class="plain-syntax">, </span><span class="identifier-syntax">ssp_pos</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">IDTypeData::get_say_data</span><span class="plain-syntax">(&amp;(</span><span class="identifier-syntax">idb</span><span class="plain-syntax">-&gt;</span><span class="identifier-syntax">type_data</span><span class="plain-syntax">.</span><span class="identifier-syntax">as_say</span><span class="plain-syntax">), &amp;</span><span class="identifier-syntax">say_cs</span><span class="plain-syntax">, &amp;</span><span class="identifier-syntax">ssp_tok</span><span class="plain-syntax">, &amp;</span><span class="identifier-syntax">ssp_ctok</span><span class="plain-syntax">, &amp;</span><span class="identifier-syntax">ssp_pos</span><span class="plain-syntax">);</span>

<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">ssp_pos</span><span class="plain-syntax"> == </span><span class="identifier-syntax">SSP_START</span><span class="plain-syntax">) </span><span class="named-paragraph-container code-font"><a href="5-cbal.html#SP8_1_1" class="named-paragraph-link"><span class="named-paragraph">This starts a complex SSP</span><span class="named-paragraph-number">8.1.1</span></a></span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">ssp_pos</span><span class="plain-syntax"> == </span><span class="identifier-syntax">SSP_MIDDLE</span><span class="plain-syntax">) </span><span class="named-paragraph-container code-font"><a href="5-cbal.html#SP8_1_2" class="named-paragraph-link"><span class="named-paragraph">This is a middle term in a complex SSP</span><span class="named-paragraph-number">8.1.2</span></a></span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">ssp_pos</span><span class="plain-syntax"> == </span><span class="identifier-syntax">SSP_END</span><span class="plain-syntax">) </span><span class="named-paragraph-container code-font"><a href="5-cbal.html#SP8_1_3" class="named-paragraph-link"><span class="named-paragraph">This ends a complex SSP</span><span class="named-paragraph-number">8.1.3</span></a></span><span class="plain-syntax">;</span>

<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">say_cs</span><span class="plain-syntax"> == </span><span class="identifier-syntax">IF_SAY_CS</span><span class="plain-syntax">) </span><span class="named-paragraph-container code-font"><a href="5-cbal.html#SP8_1_4" class="named-paragraph-link"><span class="named-paragraph">This is a say if</span><span class="named-paragraph-number">8.1.4</span></a></span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> ((</span><span class="identifier-syntax">say_cs</span><span class="plain-syntax"> == </span><span class="identifier-syntax">OTHERWISE_SAY_CS</span><span class="plain-syntax">) || (</span><span class="identifier-syntax">say_cs</span><span class="plain-syntax"> == </span><span class="identifier-syntax">OTHERWISE_IF_SAY_CS</span><span class="plain-syntax">))</span>
<span class="plain-syntax">        </span><span class="named-paragraph-container code-font"><a href="5-cbal.html#SP8_1_5" class="named-paragraph-link"><span class="named-paragraph">This is a say otherwise</span><span class="named-paragraph-number">8.1.5</span></a></span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">say_cs</span><span class="plain-syntax"> == </span><span class="identifier-syntax">END_IF_SAY_CS</span><span class="plain-syntax">) </span><span class="named-paragraph-container code-font"><a href="5-cbal.html#SP8_1_6" class="named-paragraph-link"><span class="named-paragraph">This is a say end if</span><span class="named-paragraph-number">8.1.6</span></a></span><span class="plain-syntax">;</span>
</pre>
<ul class="endnotetexts"><li>This code is used in <a href="5-cbal.html#SP8">&#167;8</a>.</li></ul>
<p class="commentary firstcommentary"><a id="SP8_1_1" class="paragraph-anchor"></a><b>&#167;8.1.1. </b><span class="named-paragraph-container code-font"><span class="named-paragraph-defn">This starts a complex SSP</span><span class="named-paragraph-number">8.1.1</span></span><span class="comment-syntax"> =</span>
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">SSP_sp</span><span class="plain-syntax"> &gt;= </span><span class="constant-syntax">MAX_COMPLEX_SAY_DEPTH</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">        </span><span class="named-paragraph-container code-font"><a href="5-cbal.html#SP8_1_1_1" class="named-paragraph-link"><span class="named-paragraph">Issue a problem message for an overcomplex SSP</span><span class="named-paragraph-number">8.1.1.1</span></a></span><span class="plain-syntax">;</span>
<span class="plain-syntax">    } </span><span class="reserved-syntax">else</span><span class="plain-syntax"> {</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">SSP_invocations</span><span class="plain-syntax">[</span><span class="identifier-syntax">SSP_sp</span><span class="plain-syntax">] = </span><span class="identifier-syntax">inv</span><span class="plain-syntax">;</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">SSP_stack_otherwised</span><span class="plain-syntax">[</span><span class="identifier-syntax">SSP_sp</span><span class="plain-syntax">] = </span><span class="identifier-syntax">FALSE</span><span class="plain-syntax">;</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">SSP_stack</span><span class="plain-syntax">[</span><span class="identifier-syntax">SSP_sp</span><span class="plain-syntax">++] = </span><span class="identifier-syntax">ssp_tok</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    }</span>
</pre>
<ul class="endnotetexts"><li>This code is used in <a href="5-cbal.html#SP8_1">&#167;8.1</a>.</li></ul>
<p class="commentary firstcommentary"><a id="SP8_1_2" class="paragraph-anchor"></a><b>&#167;8.1.2. </b><span class="named-paragraph-container code-font"><span class="named-paragraph-defn">This is a middle term in a complex SSP</span><span class="named-paragraph-number">8.1.2</span></span><span class="comment-syntax"> =</span>
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> ((</span><span class="identifier-syntax">SSP_sp</span><span class="plain-syntax"> &gt; </span><span class="constant-syntax">0</span><span class="plain-syntax">) &amp;&amp; (</span><span class="identifier-syntax">SSP_stack</span><span class="plain-syntax">[</span><span class="identifier-syntax">SSP_sp</span><span class="plain-syntax">-1] != -1) &amp;&amp;</span>
<span class="plain-syntax">        (</span><span class="identifier-syntax">compare_words</span><span class="plain-syntax">(</span><span class="identifier-syntax">SSP_stack</span><span class="plain-syntax">[</span><span class="identifier-syntax">SSP_sp</span><span class="plain-syntax">-1], </span><span class="identifier-syntax">ssp_tok</span><span class="plain-syntax">))) {</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">Annotations::write_int</span><span class="plain-syntax">(</span><span class="identifier-syntax">SSP_invocations</span><span class="plain-syntax">[</span><span class="identifier-syntax">SSP_sp</span><span class="plain-syntax">-1], </span><span class="identifier-syntax">ssp_segment_count_ANNOT</span><span class="plain-syntax">,</span>
<span class="plain-syntax">            </span><span class="identifier-syntax">Annotations::read_int</span><span class="plain-syntax">(</span><span class="identifier-syntax">SSP_invocations</span><span class="plain-syntax">[</span><span class="identifier-syntax">SSP_sp</span><span class="plain-syntax">-1], </span><span class="identifier-syntax">ssp_segment_count_ANNOT</span><span class="plain-syntax">)+1);</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">Annotations::write_int</span><span class="plain-syntax">(</span><span class="identifier-syntax">inv</span><span class="plain-syntax">, </span><span class="identifier-syntax">ssp_segment_count_ANNOT</span><span class="plain-syntax">,</span>
<span class="plain-syntax">            </span><span class="identifier-syntax">Annotations::read_int</span><span class="plain-syntax">(</span><span class="identifier-syntax">SSP_invocations</span><span class="plain-syntax">[</span><span class="identifier-syntax">SSP_sp</span><span class="plain-syntax">-1], </span><span class="identifier-syntax">ssp_segment_count_ANNOT</span><span class="plain-syntax">));</span>
<span class="plain-syntax">    } </span><span class="reserved-syntax">else</span><span class="plain-syntax"> </span><span class="named-paragraph-container code-font"><a href="5-cbal.html#SP8_1_2_1" class="named-paragraph-link"><span class="named-paragraph">Issue a problem message for middle without start</span><span class="named-paragraph-number">8.1.2.1</span></a></span><span class="plain-syntax">;</span>
</pre>
<ul class="endnotetexts"><li>This code is used in <a href="5-cbal.html#SP8_1">&#167;8.1</a>.</li></ul>
<p class="commentary firstcommentary"><a id="SP8_1_3" class="paragraph-anchor"></a><b>&#167;8.1.3. </b><span class="named-paragraph-container code-font"><span class="named-paragraph-defn">This ends a complex SSP</span><span class="named-paragraph-number">8.1.3</span></span><span class="comment-syntax"> =</span>
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> ((</span><span class="identifier-syntax">SSP_sp</span><span class="plain-syntax"> &gt; </span><span class="constant-syntax">0</span><span class="plain-syntax">) &amp;&amp; (</span><span class="identifier-syntax">SSP_stack</span><span class="plain-syntax">[</span><span class="identifier-syntax">SSP_sp</span><span class="plain-syntax">-1] != -1) &amp;&amp;</span>
<span class="plain-syntax">        (</span><span class="identifier-syntax">compare_words</span><span class="plain-syntax">(</span><span class="identifier-syntax">SSP_stack</span><span class="plain-syntax">[</span><span class="identifier-syntax">SSP_sp</span><span class="plain-syntax">-1], </span><span class="identifier-syntax">ssp_tok</span><span class="plain-syntax">))) {</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">Annotations::write_int</span><span class="plain-syntax">(</span><span class="identifier-syntax">SSP_invocations</span><span class="plain-syntax">[</span><span class="identifier-syntax">SSP_sp</span><span class="plain-syntax">-1], </span><span class="identifier-syntax">ssp_segment_count_ANNOT</span><span class="plain-syntax">,</span>
<span class="plain-syntax">            </span><span class="identifier-syntax">Annotations::read_int</span><span class="plain-syntax">(</span><span class="identifier-syntax">SSP_invocations</span><span class="plain-syntax">[</span><span class="identifier-syntax">SSP_sp</span><span class="plain-syntax">-1], </span><span class="identifier-syntax">ssp_segment_count_ANNOT</span><span class="plain-syntax">)+1);</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">Annotations::write_int</span><span class="plain-syntax">(</span><span class="identifier-syntax">SSP_invocations</span><span class="plain-syntax">[</span><span class="identifier-syntax">SSP_sp</span><span class="plain-syntax">-1], </span><span class="identifier-syntax">ssp_closing_segment_wn_ANNOT</span><span class="plain-syntax">, </span><span class="identifier-syntax">ssp_ctok</span><span class="plain-syntax">);</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">Annotations::write_int</span><span class="plain-syntax">(</span><span class="identifier-syntax">inv</span><span class="plain-syntax">, </span><span class="identifier-syntax">ssp_segment_count_ANNOT</span><span class="plain-syntax">,</span>
<span class="plain-syntax">            </span><span class="identifier-syntax">Annotations::read_int</span><span class="plain-syntax">(</span><span class="identifier-syntax">SSP_invocations</span><span class="plain-syntax">[</span><span class="identifier-syntax">SSP_sp</span><span class="plain-syntax">-1], </span><span class="identifier-syntax">ssp_segment_count_ANNOT</span><span class="plain-syntax">));</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">SSP_sp</span><span class="plain-syntax">--;</span>
<span class="plain-syntax">    } </span><span class="reserved-syntax">else</span><span class="plain-syntax"> </span><span class="named-paragraph-container code-font"><a href="5-cbal.html#SP8_1_3_1" class="named-paragraph-link"><span class="named-paragraph">Issue a problem message for end without start</span><span class="named-paragraph-number">8.1.3.1</span></a></span><span class="plain-syntax">;</span>
</pre>
<ul class="endnotetexts"><li>This code is used in <a href="5-cbal.html#SP8_1">&#167;8.1</a>.</li></ul>
<p class="commentary firstcommentary"><a id="SP8_1_4" class="paragraph-anchor"></a><b>&#167;8.1.4. </b><span class="named-paragraph-container code-font"><span class="named-paragraph-defn">This is a say if</span><span class="named-paragraph-number">8.1.4</span></span><span class="comment-syntax"> =</span>
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">say_if_nesting</span><span class="plain-syntax"> == </span><span class="constant-syntax">0</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">say_if_nesting</span><span class="plain-syntax">++;</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">SSP_invocations</span><span class="plain-syntax">[</span><span class="identifier-syntax">SSP_sp</span><span class="plain-syntax">] = </span><span class="identifier-syntax">NULL</span><span class="plain-syntax">;</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">SSP_stack_otherwised</span><span class="plain-syntax">[</span><span class="identifier-syntax">SSP_sp</span><span class="plain-syntax">] = </span><span class="identifier-syntax">FALSE</span><span class="plain-syntax">;</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">SSP_stack</span><span class="plain-syntax">[</span><span class="identifier-syntax">SSP_sp</span><span class="plain-syntax">++] = -1;</span>
<span class="plain-syntax">    } </span><span class="reserved-syntax">else</span><span class="plain-syntax"> </span><span class="named-paragraph-container code-font"><a href="5-cbal.html#SP8_1_4_1" class="named-paragraph-link"><span class="named-paragraph">Issue a problem message for nested say if</span><span class="named-paragraph-number">8.1.4.1</span></a></span><span class="plain-syntax">;</span>
</pre>
<ul class="endnotetexts"><li>This code is used in <a href="5-cbal.html#SP8_1">&#167;8.1</a>.</li></ul>
<p class="commentary firstcommentary"><a id="SP8_1_5" class="paragraph-anchor"></a><b>&#167;8.1.5. </b><span class="named-paragraph-container code-font"><span class="named-paragraph-defn">This is a say otherwise</span><span class="named-paragraph-number">8.1.5</span></span><span class="comment-syntax"> =</span>
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">say_if_nesting</span><span class="plain-syntax"> == </span><span class="constant-syntax">0</span><span class="plain-syntax">)</span>
<span class="plain-syntax">        </span><span class="named-paragraph-container code-font"><a href="5-cbal.html#SP8_1_5_1" class="named-paragraph-link"><span class="named-paragraph">Issue a problem message for say otherwise without say if</span><span class="named-paragraph-number">8.1.5.1</span></a></span>
<span class="plain-syntax">    </span><span class="reserved-syntax">else</span><span class="plain-syntax"> </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">SSP_sp</span><span class="plain-syntax"> &gt; </span><span class="constant-syntax">0</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">SSP_stack</span><span class="plain-syntax">[</span><span class="identifier-syntax">SSP_sp</span><span class="plain-syntax">-1] != -1)</span>
<span class="plain-syntax">            </span><span class="named-paragraph-container code-font"><a href="5-cbal.html#SP8_1_5_2" class="named-paragraph-link"><span class="named-paragraph">Issue a problem message for say otherwise interleaved with another construction</span><span class="named-paragraph-number">8.1.5.2</span></a></span><span class="plain-syntax">;</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">SSP_stack_otherwised</span><span class="plain-syntax">[</span><span class="identifier-syntax">SSP_sp</span><span class="plain-syntax">-1])</span>
<span class="plain-syntax">            </span><span class="named-paragraph-container code-font"><a href="5-cbal.html#SP8_1_5_3" class="named-paragraph-link"><span class="named-paragraph">Issue a problem message for two say otherwises</span><span class="named-paragraph-number">8.1.5.3</span></a></span>
<span class="plain-syntax">        </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">say_cs</span><span class="plain-syntax"> == </span><span class="identifier-syntax">OTHERWISE_SAY_CS</span><span class="plain-syntax">) </span><span class="identifier-syntax">SSP_stack_otherwised</span><span class="plain-syntax">[</span><span class="identifier-syntax">SSP_sp</span><span class="plain-syntax">-1] = </span><span class="identifier-syntax">TRUE</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    }</span>
</pre>
<ul class="endnotetexts"><li>This code is used in <a href="5-cbal.html#SP8_1">&#167;8.1</a>.</li></ul>
<p class="commentary firstcommentary"><a id="SP8_1_6" class="paragraph-anchor"></a><b>&#167;8.1.6. </b><span class="named-paragraph-container code-font"><span class="named-paragraph-defn">This is a say end if</span><span class="named-paragraph-number">8.1.6</span></span><span class="comment-syntax"> =</span>
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">say_if_nesting</span><span class="plain-syntax"> == </span><span class="constant-syntax">0</span><span class="plain-syntax">)</span>
<span class="plain-syntax">        </span><span class="named-paragraph-container code-font"><a href="5-cbal.html#SP8_1_6_1" class="named-paragraph-link"><span class="named-paragraph">Issue a problem message for say end if without say if</span><span class="named-paragraph-number">8.1.6.1</span></a></span>
<span class="plain-syntax">    </span><span class="reserved-syntax">else</span><span class="plain-syntax"> </span><span class="reserved-syntax">if</span><span class="plain-syntax"> ((</span><span class="identifier-syntax">SSP_sp</span><span class="plain-syntax"> &gt; </span><span class="constant-syntax">0</span><span class="plain-syntax">) &amp;&amp; (</span><span class="identifier-syntax">SSP_stack</span><span class="plain-syntax">[</span><span class="identifier-syntax">SSP_sp</span><span class="plain-syntax">-1] != -1))</span>
<span class="plain-syntax">        </span><span class="named-paragraph-container code-font"><a href="5-cbal.html#SP8_1_6_2" class="named-paragraph-link"><span class="named-paragraph">Issue a problem message for say end if interleaved with another construction</span><span class="named-paragraph-number">8.1.6.2</span></a></span>
<span class="plain-syntax">    </span><span class="reserved-syntax">else</span><span class="plain-syntax"> {</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">say_if_nesting</span><span class="plain-syntax">--;</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">SSP_sp</span><span class="plain-syntax">--;</span>
<span class="plain-syntax">    }</span>
</pre>
<ul class="endnotetexts"><li>This code is used in <a href="5-cbal.html#SP8_1">&#167;8.1</a>.</li></ul>
<p class="commentary firstcommentary"><a id="SP8_1_2_1" class="paragraph-anchor"></a><b>&#167;8.1.2.1. </b><span class="named-paragraph-container code-font"><span class="named-paragraph-defn">Issue a problem message for middle without start</span><span class="named-paragraph-number">8.1.2.1</span></span><span class="comment-syntax"> =</span>
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">problem_issued</span><span class="plain-syntax"> == </span><span class="identifier-syntax">FALSE</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">Problems::quote_source</span><span class="plain-syntax">(1, </span><span class="identifier-syntax">current_sentence</span><span class="plain-syntax">);</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">Problems::quote_wording</span><span class="plain-syntax">(2, </span><span class="identifier-syntax">Node::get_text</span><span class="plain-syntax">(</span><span class="identifier-syntax">inv</span><span class="plain-syntax">));</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">StandardProblems::handmade_problem</span><span class="plain-syntax">(</span><span class="identifier-syntax">Task::syntax_tree</span><span class="plain-syntax">(),</span>
<span class="plain-syntax">            </span><span class="identifier-syntax">_p_</span><span class="plain-syntax">(</span><span class="identifier-syntax">PM_ComplicatedSayStructure</span><span class="plain-syntax">));</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">Problems::issue_problem_segment</span><span class="plain-syntax">(</span>
<span class="plain-syntax">            </span><span class="string-syntax">"In the text at %1, the text substitution '[%2]' ought to occur as the "</span>
<span class="plain-syntax">            </span><span class="string-syntax">"middle part of its construction, but it appears to be on its own."</span><span class="plain-syntax">);</span>
<span class="plain-syntax">        </span><a href="5-cbal.html#SP9" class="function-link"><span class="function-syntax">CompileBlocksAndLines::add_say_construction_to_error</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">ssp_tok</span><span class="plain-syntax">);</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">Problems::issue_problem_end</span><span class="plain-syntax">();</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">problem_issued</span><span class="plain-syntax"> = </span><span class="identifier-syntax">TRUE</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    }</span>
</pre>
<ul class="endnotetexts"><li>This code is used in <a href="5-cbal.html#SP8_1_2">&#167;8.1.2</a>.</li></ul>
<p class="commentary firstcommentary"><a id="SP8_1_3_1" class="paragraph-anchor"></a><b>&#167;8.1.3.1. </b><span class="named-paragraph-container code-font"><span class="named-paragraph-defn">Issue a problem message for end without start</span><span class="named-paragraph-number">8.1.3.1</span></span><span class="comment-syntax"> =</span>
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">problem_issued</span><span class="plain-syntax"> == </span><span class="identifier-syntax">FALSE</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">Problems::quote_source</span><span class="plain-syntax">(1, </span><span class="identifier-syntax">current_sentence</span><span class="plain-syntax">);</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">Problems::quote_wording</span><span class="plain-syntax">(2, </span><span class="identifier-syntax">Node::get_text</span><span class="plain-syntax">(</span><span class="identifier-syntax">inv</span><span class="plain-syntax">));</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">StandardProblems::handmade_problem</span><span class="plain-syntax">(</span><span class="identifier-syntax">Task::syntax_tree</span><span class="plain-syntax">(),</span>
<span class="plain-syntax">            </span><span class="identifier-syntax">_p_</span><span class="plain-syntax">(</span><span class="identifier-syntax">PM_ComplicatedSayStructure2</span><span class="plain-syntax">));</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">Problems::issue_problem_segment</span><span class="plain-syntax">(</span>
<span class="plain-syntax">            </span><span class="string-syntax">"In the text at %1, the text substitution '[%2]' ought to occur as the "</span>
<span class="plain-syntax">            </span><span class="string-syntax">"ending part of its construction, but it appears to be on its own."</span><span class="plain-syntax">);</span>
<span class="plain-syntax">        </span><a href="5-cbal.html#SP9" class="function-link"><span class="function-syntax">CompileBlocksAndLines::add_say_construction_to_error</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">ssp_tok</span><span class="plain-syntax">);</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">Problems::issue_problem_end</span><span class="plain-syntax">();</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">problem_issued</span><span class="plain-syntax"> = </span><span class="identifier-syntax">TRUE</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    }</span>
</pre>
<ul class="endnotetexts"><li>This code is used in <a href="5-cbal.html#SP8_1_3">&#167;8.1.3</a>.</li></ul>
<p class="commentary firstcommentary"><a id="SP8_1_4_1" class="paragraph-anchor"></a><b>&#167;8.1.4.1. </b><span class="named-paragraph-container code-font"><span class="named-paragraph-defn">Issue a problem message for nested say if</span><span class="named-paragraph-number">8.1.4.1</span></span><span class="comment-syntax"> =</span>
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">problem_issued</span><span class="plain-syntax"> == </span><span class="identifier-syntax">FALSE</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">StandardProblems::sentence_problem</span><span class="plain-syntax">(</span><span class="identifier-syntax">Task::syntax_tree</span><span class="plain-syntax">(),</span>
<span class="plain-syntax">            </span><span class="identifier-syntax">_p_</span><span class="plain-syntax">(</span><span class="identifier-syntax">PM_SayIfNested</span><span class="plain-syntax">),</span>
<span class="plain-syntax">            </span><span class="string-syntax">"a second '[if ...]' text substitution occurs inside an existing one"</span><span class="plain-syntax">,</span>
<span class="plain-syntax">            </span><span class="string-syntax">"which makes this text too complicated. While a single text can contain "</span>
<span class="plain-syntax">            </span><span class="string-syntax">"more than one '[if ...]', this can only happen if the old if is finished "</span>
<span class="plain-syntax">            </span><span class="string-syntax">"with an '[end if]' or the new one is written '[otherwise if]'. If you "</span>
<span class="plain-syntax">            </span><span class="string-syntax">"need more complicated variety than this allows, the best approach is "</span>
<span class="plain-syntax">            </span><span class="string-syntax">"to define a new text substitution of your own ('To say fiddly details: "</span>
<span class="plain-syntax">            </span><span class="string-syntax">"...') and then use it in this text by including the '[fiddly details]'."</span><span class="plain-syntax">);</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">problem_issued</span><span class="plain-syntax"> = </span><span class="identifier-syntax">TRUE</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    }</span>
</pre>
<ul class="endnotetexts"><li>This code is used in <a href="5-cbal.html#SP8_1_4">&#167;8.1.4</a>.</li></ul>
<p class="commentary firstcommentary"><a id="SP8_1_1_1" class="paragraph-anchor"></a><b>&#167;8.1.1.1. </b><span class="named-paragraph-container code-font"><span class="named-paragraph-defn">Issue a problem message for an overcomplex SSP</span><span class="named-paragraph-number">8.1.1.1</span></span><span class="comment-syntax"> =</span>
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">problem_issued</span><span class="plain-syntax"> == </span><span class="identifier-syntax">FALSE</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">StandardProblems::sentence_problem</span><span class="plain-syntax">(</span><span class="identifier-syntax">Task::syntax_tree</span><span class="plain-syntax">(),</span>
<span class="plain-syntax">            </span><span class="identifier-syntax">_p_</span><span class="plain-syntax">(</span><span class="identifier-syntax">PM_SayOverComplex</span><span class="plain-syntax">),</span>
<span class="plain-syntax">            </span><span class="string-syntax">"this is too complex a text substitution"</span><span class="plain-syntax">,</span>
<span class="plain-syntax">            </span><span class="string-syntax">"and needs to be simplified. You might find it helpful to define a new text "</span>
<span class="plain-syntax">            </span><span class="string-syntax">"substitution of your own ('To say fiddly details: ...') and then use it "</span>
<span class="plain-syntax">            </span><span class="string-syntax">"in this text by including the '[fiddly details]'."</span><span class="plain-syntax">);</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">problem_issued</span><span class="plain-syntax"> = </span><span class="identifier-syntax">TRUE</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    }</span>
</pre>
<ul class="endnotetexts"><li>This code is used in <a href="5-cbal.html#SP8_1_1">&#167;8.1.1</a>.</li></ul>
<p class="commentary firstcommentary"><a id="SP8_1_5_1" class="paragraph-anchor"></a><b>&#167;8.1.5.1. </b><span class="named-paragraph-container code-font"><span class="named-paragraph-defn">Issue a problem message for say otherwise without say if</span><span class="named-paragraph-number">8.1.5.1</span></span><span class="comment-syntax"> =</span>
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">problem_issued</span><span class="plain-syntax"> == </span><span class="identifier-syntax">FALSE</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">StandardProblems::sentence_problem</span><span class="plain-syntax">(</span><span class="identifier-syntax">Task::syntax_tree</span><span class="plain-syntax">(),</span>
<span class="plain-syntax">            </span><span class="identifier-syntax">_p_</span><span class="plain-syntax">(</span><span class="identifier-syntax">PM_SayOtherwiseWithoutIf</span><span class="plain-syntax">),</span>
<span class="plain-syntax">            </span><span class="string-syntax">"an '[otherwise]' text substitution occurs where there appears to be no "</span>
<span class="plain-syntax">            </span><span class="string-syntax">"[if ...]"</span><span class="plain-syntax">,</span>
<span class="plain-syntax">            </span><span class="string-syntax">"which doesn't make sense - there is nothing for it to be otherwise to."</span><span class="plain-syntax">);</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">problem_issued</span><span class="plain-syntax"> = </span><span class="identifier-syntax">TRUE</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    }</span>
</pre>
<ul class="endnotetexts"><li>This code is used in <a href="5-cbal.html#SP8_1_5">&#167;8.1.5</a>.</li></ul>
<p class="commentary firstcommentary"><a id="SP8_1_5_2" class="paragraph-anchor"></a><b>&#167;8.1.5.2. </b><span class="named-paragraph-container code-font"><span class="named-paragraph-defn">Issue a problem message for say otherwise interleaved with another construction</span><span class="named-paragraph-number">8.1.5.2</span></span><span class="comment-syntax"> =</span>
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">problem_issued</span><span class="plain-syntax"> == </span><span class="identifier-syntax">FALSE</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">Problems::quote_source</span><span class="plain-syntax">(1, </span><span class="identifier-syntax">current_sentence</span><span class="plain-syntax">);</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">Problems::quote_wording</span><span class="plain-syntax">(2, </span><span class="identifier-syntax">Node::get_text</span><span class="plain-syntax">(</span><span class="identifier-syntax">inv</span><span class="plain-syntax">));</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">StandardProblems::handmade_problem</span><span class="plain-syntax">(</span><span class="identifier-syntax">Task::syntax_tree</span><span class="plain-syntax">(),</span>
<span class="plain-syntax">            </span><span class="identifier-syntax">_p_</span><span class="plain-syntax">(</span><span class="identifier-syntax">PM_ComplicatedSayStructure5</span><span class="plain-syntax">));</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">Problems::issue_problem_segment</span><span class="plain-syntax">(</span>
<span class="plain-syntax">            </span><span class="string-syntax">"In the text at %1, the '[%2]' ought to occur inside an [if ...], but is cut "</span>
<span class="plain-syntax">            </span><span class="string-syntax">"off because it has been interleaved with a complicated say construction."</span><span class="plain-syntax">);</span>
<span class="plain-syntax">        </span><a href="5-cbal.html#SP9" class="function-link"><span class="function-syntax">CompileBlocksAndLines::add_say_construction_to_error</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">SSP_stack</span><span class="plain-syntax">[</span><span class="identifier-syntax">SSP_sp</span><span class="plain-syntax">-1]);</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">Problems::issue_problem_end</span><span class="plain-syntax">();</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">problem_issued</span><span class="plain-syntax"> = </span><span class="identifier-syntax">TRUE</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    }</span>
</pre>
<ul class="endnotetexts"><li>This code is used in <a href="5-cbal.html#SP8_1_5">&#167;8.1.5</a>.</li></ul>
<p class="commentary firstcommentary"><a id="SP8_1_5_3" class="paragraph-anchor"></a><b>&#167;8.1.5.3. </b><span class="named-paragraph-container code-font"><span class="named-paragraph-defn">Issue a problem message for two say otherwises</span><span class="named-paragraph-number">8.1.5.3</span></span><span class="comment-syntax"> =</span>
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">problem_issued</span><span class="plain-syntax"> == </span><span class="identifier-syntax">FALSE</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">StandardProblems::sentence_problem</span><span class="plain-syntax">(</span><span class="identifier-syntax">Task::syntax_tree</span><span class="plain-syntax">(),</span>
<span class="plain-syntax">            </span><span class="identifier-syntax">_p_</span><span class="plain-syntax">(</span><span class="identifier-syntax">PM_TwoSayOtherwises</span><span class="plain-syntax">),</span>
<span class="plain-syntax">            </span><span class="string-syntax">"there's already an (unconditional) \"[otherwise]\" or \"[else]\" in this "</span>
<span class="plain-syntax">            </span><span class="string-syntax">"text substitution"</span><span class="plain-syntax">,</span>
<span class="plain-syntax">            </span><span class="string-syntax">"so it doesn't make sense to follow that with a further one."</span><span class="plain-syntax">);</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">problem_issued</span><span class="plain-syntax"> = </span><span class="identifier-syntax">TRUE</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    }</span>
</pre>
<ul class="endnotetexts"><li>This code is used in <a href="5-cbal.html#SP8_1_5">&#167;8.1.5</a>.</li></ul>
<p class="commentary firstcommentary"><a id="SP8_1_6_1" class="paragraph-anchor"></a><b>&#167;8.1.6.1. </b><span class="named-paragraph-container code-font"><span class="named-paragraph-defn">Issue a problem message for say end if without say if</span><span class="named-paragraph-number">8.1.6.1</span></span><span class="comment-syntax"> =</span>
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">problem_issued</span><span class="plain-syntax"> == </span><span class="identifier-syntax">FALSE</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">StandardProblems::sentence_problem</span><span class="plain-syntax">(</span><span class="identifier-syntax">Task::syntax_tree</span><span class="plain-syntax">(),</span>
<span class="plain-syntax">            </span><span class="identifier-syntax">_p_</span><span class="plain-syntax">(</span><span class="identifier-syntax">PM_SayEndIfWithoutSayIf</span><span class="plain-syntax">),</span>
<span class="plain-syntax">            </span><span class="string-syntax">"an '[end if]' text substitution occurs where there appears to be no "</span>
<span class="plain-syntax">            </span><span class="string-syntax">"[if ...]"</span><span class="plain-syntax">,</span>
<span class="plain-syntax">            </span><span class="string-syntax">"which doesn't make sense - there is nothing for it to end."</span><span class="plain-syntax">);</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">problem_issued</span><span class="plain-syntax"> = </span><span class="identifier-syntax">TRUE</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    }</span>
</pre>
<ul class="endnotetexts"><li>This code is used in <a href="5-cbal.html#SP8_1_6">&#167;8.1.6</a>.</li></ul>
<p class="commentary firstcommentary"><a id="SP8_1_6_2" class="paragraph-anchor"></a><b>&#167;8.1.6.2. </b><span class="named-paragraph-container code-font"><span class="named-paragraph-defn">Issue a problem message for say end if interleaved with another construction</span><span class="named-paragraph-number">8.1.6.2</span></span><span class="comment-syntax"> =</span>
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">problem_issued</span><span class="plain-syntax"> == </span><span class="identifier-syntax">FALSE</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">Problems::quote_source</span><span class="plain-syntax">(1, </span><span class="identifier-syntax">current_sentence</span><span class="plain-syntax">);</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">Problems::quote_wording</span><span class="plain-syntax">(2, </span><span class="identifier-syntax">Node::get_text</span><span class="plain-syntax">(</span><span class="identifier-syntax">inv</span><span class="plain-syntax">));</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">StandardProblems::handmade_problem</span><span class="plain-syntax">(</span><span class="identifier-syntax">Task::syntax_tree</span><span class="plain-syntax">(),</span>
<span class="plain-syntax">            </span><span class="identifier-syntax">_p_</span><span class="plain-syntax">(</span><span class="identifier-syntax">PM_ComplicatedSayStructure4</span><span class="plain-syntax">));</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">Problems::issue_problem_segment</span><span class="plain-syntax">(</span>
<span class="plain-syntax">            </span><span class="string-syntax">"In the text at %1, the '[%2]' is cut off from its [if ...], because it "</span>
<span class="plain-syntax">            </span><span class="string-syntax">"has been interleaved with a complicated say construction."</span><span class="plain-syntax">);</span>
<span class="plain-syntax">        </span><a href="5-cbal.html#SP9" class="function-link"><span class="function-syntax">CompileBlocksAndLines::add_say_construction_to_error</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">SSP_stack</span><span class="plain-syntax">[</span><span class="identifier-syntax">SSP_sp</span><span class="plain-syntax">-1]);</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">Problems::issue_problem_end</span><span class="plain-syntax">();</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">problem_issued</span><span class="plain-syntax"> = </span><span class="identifier-syntax">TRUE</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    }</span>
</pre>
<ul class="endnotetexts"><li>This code is used in <a href="5-cbal.html#SP8_1_6">&#167;8.1.6</a>.</li></ul>
<p class="commentary firstcommentary"><a id="SP8_2" class="paragraph-anchor"></a><b>&#167;8.2. </b><span class="named-paragraph-container code-font"><span class="named-paragraph-defn">Issue a problem message for an SSP without end</span><span class="named-paragraph-number">8.2</span></span><span class="comment-syntax"> =</span>
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">problem_issued</span><span class="plain-syntax"> == </span><span class="identifier-syntax">FALSE</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">parse_node</span><span class="plain-syntax"> *</span><span class="identifier-syntax">stinv</span><span class="plain-syntax"> = </span><span class="identifier-syntax">NULL</span><span class="plain-syntax">;</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">int</span><span class="plain-syntax"> </span><span class="identifier-syntax">i</span><span class="plain-syntax">, </span><span class="identifier-syntax">ssp_tok</span><span class="plain-syntax"> = -1;</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">for</span><span class="plain-syntax"> (</span><span class="identifier-syntax">i</span><span class="plain-syntax">=0; </span><span class="identifier-syntax">i</span><span class="plain-syntax">&lt;</span><span class="identifier-syntax">SSP_sp</span><span class="plain-syntax">; </span><span class="identifier-syntax">i</span><span class="plain-syntax">++)</span>
<span class="plain-syntax">            </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">SSP_invocations</span><span class="plain-syntax">[</span><span class="identifier-syntax">i</span><span class="plain-syntax">]) {</span>
<span class="plain-syntax">                </span><span class="identifier-syntax">stinv</span><span class="plain-syntax"> = </span><span class="identifier-syntax">SSP_invocations</span><span class="plain-syntax">[</span><span class="identifier-syntax">i</span><span class="plain-syntax">];</span>
<span class="plain-syntax">                </span><span class="identifier-syntax">ssp_tok</span><span class="plain-syntax"> = </span><span class="identifier-syntax">SSP_stack</span><span class="plain-syntax">[</span><span class="identifier-syntax">i</span><span class="plain-syntax">];</span>
<span class="plain-syntax">            }</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">stinv</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">            </span><span class="identifier-syntax">Problems::quote_source</span><span class="plain-syntax">(1, </span><span class="identifier-syntax">current_sentence</span><span class="plain-syntax">);</span>
<span class="plain-syntax">            </span><span class="identifier-syntax">Problems::quote_wording</span><span class="plain-syntax">(2, </span><span class="identifier-syntax">Node::get_text</span><span class="plain-syntax">(</span><span class="identifier-syntax">stinv</span><span class="plain-syntax">));</span>
<span class="plain-syntax">            </span><span class="identifier-syntax">StandardProblems::handmade_problem</span><span class="plain-syntax">(</span><span class="identifier-syntax">Task::syntax_tree</span><span class="plain-syntax">(),</span>
<span class="plain-syntax">                </span><span class="identifier-syntax">_p_</span><span class="plain-syntax">(</span><span class="identifier-syntax">PM_ComplicatedSayStructure3</span><span class="plain-syntax">));</span>
<span class="plain-syntax">            </span><span class="identifier-syntax">Problems::issue_problem_segment</span><span class="plain-syntax">(</span>
<span class="plain-syntax">                </span><span class="string-syntax">"In the text at %1, the text substitution '[%2]' seems to start a "</span>
<span class="plain-syntax">                </span><span class="string-syntax">"complicated say construction, but it doesn't have a matching end."</span><span class="plain-syntax">);</span>
<span class="plain-syntax">            </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">ssp_tok</span><span class="plain-syntax"> &gt;= </span><span class="constant-syntax">0</span><span class="plain-syntax">) </span><a href="5-cbal.html#SP9" class="function-link"><span class="function-syntax">CompileBlocksAndLines::add_say_construction_to_error</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">ssp_tok</span><span class="plain-syntax">);</span>
<span class="plain-syntax">            </span><span class="identifier-syntax">Problems::issue_problem_end</span><span class="plain-syntax">();</span>
<span class="plain-syntax">            </span><span class="identifier-syntax">problem_issued</span><span class="plain-syntax"> = </span><span class="identifier-syntax">TRUE</span><span class="plain-syntax">;</span>
<span class="plain-syntax">        }</span>
<span class="plain-syntax">    }</span>
</pre>
<ul class="endnotetexts"><li>This code is used in <a href="5-cbal.html#SP8">&#167;8</a>.</li></ul>
<p class="commentary firstcommentary"><a id="SP9" class="paragraph-anchor"></a><b>&#167;9. </b>These just help to construct problem messages for complex say constructions:
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="reserved-syntax">void</span><span class="plain-syntax"> </span><span class="function-syntax">CompileBlocksAndLines::add_say_construction_to_error</span><button class="popup" onclick="togglePopup('usagePopup7')"><span class="comment-syntax">?</span><span class="popuptext" id="usagePopup7">Usage of <span class="code-font"><span class="function-syntax">CompileBlocksAndLines::add_say_construction_to_error</span></span>:<br/><a href="5-cbal.html#SP8_1_2_1">&#167;8.1.2.1</a>, <a href="5-cbal.html#SP8_1_3_1">&#167;8.1.3.1</a>, <a href="5-cbal.html#SP8_1_5_2">&#167;8.1.5.2</a>, <a href="5-cbal.html#SP8_1_6_2">&#167;8.1.6.2</a>, <a href="5-cbal.html#SP8_2">&#167;8.2</a></span></button><span class="plain-syntax">(</span><span class="reserved-syntax">int</span><span class="plain-syntax"> </span><span class="identifier-syntax">ssp_tok</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">Problems::issue_problem_segment</span><span class="plain-syntax">(</span><span class="string-syntax">" %P(The construction I'm thinking of is '"</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><a href="5-cbal.html#SP9" class="function-link"><span class="function-syntax">CompileBlocksAndLines::add_scte_list</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">ssp_tok</span><span class="plain-syntax">, </span><span class="identifier-syntax">SSP_START</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">Problems::issue_problem_segment</span><span class="plain-syntax">(</span><span class="string-syntax">" ... "</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><a href="5-cbal.html#SP9" class="function-link"><span class="function-syntax">CompileBlocksAndLines::add_scte_list</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">ssp_tok</span><span class="plain-syntax">, </span><span class="identifier-syntax">SSP_MIDDLE</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">Problems::issue_problem_segment</span><span class="plain-syntax">(</span><span class="string-syntax">" ... "</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><a href="5-cbal.html#SP9" class="function-link"><span class="function-syntax">CompileBlocksAndLines::add_scte_list</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">ssp_tok</span><span class="plain-syntax">, </span><span class="identifier-syntax">SSP_END</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">Problems::issue_problem_segment</span><span class="plain-syntax">(</span><span class="string-syntax">"'.)"</span><span class="plain-syntax">);</span>
<span class="plain-syntax">}</span>

<span class="reserved-syntax">void</span><span class="plain-syntax"> </span><span class="function-syntax">CompileBlocksAndLines::add_scte_list</span><span class="plain-syntax">(</span><span class="reserved-syntax">int</span><span class="plain-syntax"> </span><span class="identifier-syntax">ssp_tok</span><span class="plain-syntax">, </span><span class="reserved-syntax">int</span><span class="plain-syntax"> </span><span class="identifier-syntax">list_pos</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">id_body</span><span class="plain-syntax"> *</span><span class="identifier-syntax">idb</span><span class="plain-syntax">; </span><span class="reserved-syntax">int</span><span class="plain-syntax"> </span><span class="identifier-syntax">ct</span><span class="plain-syntax"> = </span><span class="constant-syntax">0</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">LOOP_OVER</span><span class="plain-syntax">(</span><span class="identifier-syntax">idb</span><span class="plain-syntax">, </span><span class="identifier-syntax">id_body</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">wording</span><span class="plain-syntax"> </span><span class="identifier-syntax">W</span><span class="plain-syntax">;</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">IDTypeData::ssp_matches</span><span class="plain-syntax">(&amp;(</span><span class="identifier-syntax">idb</span><span class="plain-syntax">-&gt;</span><span class="identifier-syntax">type_data</span><span class="plain-syntax">), </span><span class="identifier-syntax">ssp_tok</span><span class="plain-syntax">, </span><span class="identifier-syntax">list_pos</span><span class="plain-syntax">, &amp;</span><span class="identifier-syntax">W</span><span class="plain-syntax">)) {</span>
<span class="plain-syntax">            </span><span class="identifier-syntax">Problems::quote_wording</span><span class="plain-syntax">(3, </span><span class="identifier-syntax">W</span><span class="plain-syntax">);</span>
<span class="plain-syntax">            </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">ct</span><span class="plain-syntax">++ == </span><span class="constant-syntax">0</span><span class="plain-syntax">) </span><span class="identifier-syntax">Problems::issue_problem_segment</span><span class="plain-syntax">(</span><span class="string-syntax">"[%3]"</span><span class="plain-syntax">);</span>
<span class="plain-syntax">            </span><span class="reserved-syntax">else</span><span class="plain-syntax"> </span><span class="identifier-syntax">Problems::issue_problem_segment</span><span class="plain-syntax">(</span><span class="string-syntax">"/[%3]"</span><span class="plain-syntax">);</span>
<span class="plain-syntax">        }</span>
<span class="plain-syntax">    }</span>
<span class="plain-syntax">}</span>
</pre>
<nav role="progress"><div class="progresscontainer">
    <ul class="progressbar"><li class="progressprev"><a href="4-cdp.html">&#10094;</a></li><li class="progresschapter"><a href="P-wtmd.html">P</a></li><li class="progresschapter"><a href="1-im.html">1</a></li><li class="progresschapter"><a href="2-cv.html">2</a></li><li class="progresschapter"><a href="3-sf.html">3</a></li><li class="progresschapter"><a href="4-cs.html">4</a></li><li class="progresscurrentchapter">5</li><li class="progresscurrent">cbal</li><li class="progresssection"><a href="5-ci.html">ci</a></li><li class="progresssection"><a href="5-ciac.html">ciac</a></li><li class="progresssection"><a href="5-cii.html">cii</a></li><li class="progresssection"><a href="5-cste.html">cste</a></li><li class="progresssection"><a href="5-ca.html">ca</a></li><li class="progressnext"><a href="5-ci.html">&#10095;</a></li></ul></div>
</nav><!-- End of weave -->

		</main>
	</body>
</html>

